Primitive Data Types in Java

java dev.to

in Java, primitive data types are the most basic types of data. They store simple values (not objects) and are very fast. 1. byte Size: 1 byte (8 bits) Range: -128 to 127 Used to save memory in large arrays Example: byte b = 100; 2. short Size: 2 bytes Range: -32,768 to 32,767 Example: short s = 20000; 3. int Size: 4 bytes Most commonly used Range: -2³¹ to 2³¹-1 Example: int num = 100000; 4. long Size: 8 bytes Used for very large numbers Example: long l = 1000000000

Read Full Tutorial open_in_new
arrow_back Back to Tutorials