Basic Variable Types in Java Programming Language

Basic Variable Types in Java Programming Language (boolean, char, int, long, float, double, short, byte)

Variable Type Description Bit Value
boolean logic variable   true,false
char letter variable 16 '\u0000' den '\uFFFF'
byte integer variable 8 -128 to 127
short integer variable 16 -32768 to 32767
int integer variable 32 -2157483648 to 2147483647
long integer variable 64 -9223372036854775808 to 9223372036854775808
float real number variable 32 -3.40292347e+38 to 3.40292347e+38
double real number variable 64 -1.7976931348623157e+308 to 1.7976931348623157e+308

 

 

Boolean :

The boolean variable type is used in logic operations. It takes only true or false.
example: boolean firstvalue;
firstvalue= true;

 

Char:

char variable type is used to define letters. The letters are transferred to the computer with the ISO Unicode code in java language. Unicode is formed by the combination of hexagonal (16-based) number.

example: char X1, X2;

char character1, character2;

X1 = '\ u0041';

X2 = 'A';

character1 = '\ u03e1';

character2= '';

 

Byte:

integer variables are named according to the place they occupy in the memory. The byte takes up 8 bits in memory. The byte variable type can use a total of 256 numbers from -128 to 127.

example: int bytenumber = 64;

 

Short:

integer variables are named according to the place they occupy in the memory. It takes 16 bits in short memory. The short variable type can use from -32768 to 32767.

example: int shortnumber = 15063;

 

Int:

integer variables are named according to the place they occupy in the memory. int takes 32 bits of memory. The int variable type can use from -2157483648 to 2147483647.

example: int intnumber = 1149883645;

 

Long:

integer variables are named according to the place they occupy in the memory. it holds 64 bits in long memory. The long variable type can use from -9223372036854775808 to 9223372036854775808.

example: int longnumber = 5223372536854775805;

 

Float:

It occupies 32 bits of float memory.

example: floatnumber = 34.56;

 

Double:

It occupies 64 bits of float memory.

example: doublenumber = 22.65e-17;

 

Tagged In:

Software developer

26 Total Posts