Tuesday, 27 November 2018

Java - Data Types


Java has 8 primitive data types. Each one primitive type will have wrapper class available from java.lang.(will discuss in java.lang package).
Following list provides the primitive types and their wrapper classes.
     Integer based       Float based     Other
     int(Integer)        float(Float)    char(Character)
     long(Long)          double(Double)  boolean(Boolean)
     short(Short)
     byte(Byte)
The following table illustrates the data types and their size, ranges.
In true, false can’t be represented as 1,0 in java.
Data Type
Width(bit)
Range
int
32(4 byte)
-2,147,483,648 to 2,147,483,647
long
64(8 byte)
-9,223,372,036,854,775,808 to  9,223,372,036,854,775,807
short
16(2byte)
-32,768 to 32,767
byte
8(1 byte)
-128 to 127
double
64(8 byte)
4.9e-324 to 1.8e+308
float
32(4 byte)
1.4e-045 to 3.4e+308
char
16(2 byte)

boolean

true, false

No comments:

Post a Comment

Note: only a member of this blog may post a comment.