Data types are cornerstones of a programming language. The Java language has 8 primitive types: boolean, byte, char, double, float, int, long, and short.

A boolean type represents either true or false value.

A char type represents a single character, such as 'a', 'B', 'c', ...Actually char type is 16-bit integer number (un-signed).

The others are numeric types. The following section lists the primitive types which represent numbers in the Java language (the char type is also included because it is actually a number type):

 

Integer numbers:

  • byte: 8 bit (1 byte)

minimum value: -128 (-27)

maximum value: 127 (27-1)

  • char: 16 bit (2 bytes)

minimum value: 0

maximum value: 65,535

  • short: 16 bit (2 bytes)

minimum value: -32,768 (-215)

maximum value: 32,767 (215-1)

  • int: 32 bit (4 bytes)

minimum value:  -2,147,483,648 (-231)

maximum value: 2,147,483,647 (231-1)

  • long: 64 bit (8 bytes)

minimum value:  approx. -9,2 billions of billion (-263)

maximum value:  approx. 9,2 billions of billion (-263-1)

 

Floating-point numbers:

  • float: 32 bit (4 bytes):
  • double: 64 bit (8 bytes):
 



 

There are 4 integer types: byte, short, int, and long.

There are 2 floating point number types: float and double.

 

Related Tutorials:

 

Other Recommended Tutorials:


About the Author:

is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.



Add comment

   


Comments 

#1Andrzej2022-08-22 08:32
Hello
I would like to report you a but, in primitives types section, in long is maximum value: approx. 9,2 billions of billion (-2^63-1), shouldn't be (2^63-1)?
Quote