JAVA

Primitive Data Types

  • There are 8 Primitive Data Types available in Java.
  Java Primitive Data Types

1. Integer:

  • Integers have four types. It includes byte, short, int and long which are for whole-valued signed numbers.
  • This values can be either be positive or negative.
Type Size Range Example
Byte 8 bits -128 to +128 byte a, b;
Short 16 bits -32,768vto +32,767 short c, d;
Integer 32 bits -2,147,483,684 to +2,147,483,647 int i;
Long 64 bits -9223372036854775808 to +9223372036854775807 long x,y;
Char 16 bits 0 to 65,536 char is only unsigned char c;

2. Floating-Point Type:

  • Float is used to store numbers with decimal point.
  • There are two floating point data types. That are float and double.
Name Size Range Example
Double 32 bits 1.7e-308 to 1.7e+308 Double a,b;
Float 64 bits 3.4e-038 to 3.4e+038 Float a, b;

3. Characters:

  • It is used for storing individual characters.
  • The character type has 16-bits of precision and it is unsigned.
  • The range of char is 0 to 65,536 and there are no negative characters.
  • Java uses Unicode to represent characters. Unicode defines a fully international characters set that can represent all of the characters in all human languages.

4. Booleans:

  • Boolean data types hold either a true or false value.
  • These are not stored as numeric values and cannot be used as such.
  • This is the type returned by all relations operators.



Subscribe us on Youtube

Share This Page on


Ask Question