There are majorly two types of languages. First one is Statically typed language where each variable and expression type is already known at compile time.Once a variable is declared to be of a certain data type, it cannot hold values of other data types.Example: C,C++, Java. Other, Dynamically typed languages: These languages can receive different data types over the time. Ruby, Python
Java has two categories of data:
Primitive data are only single values; they have no special capabilities.
The eight primitive data types in Java are:
Values of class type are references. Strings are references to an instance of class String.
|boolean||false||1 bit||true, false|
|char||\u0000||16 bits||'a', '\u0041', '\101', '\\', '\'', '\n', 'ß'|
|int||0||32 bits||-2, -1, 0, 1, 2|
|long||0||64 bits||-2L, -1L, 0L, 1L, 2L|
|float||0.0||32 bits||1.23e100f, -1.23e-100f, .3f, 3.14F|
|double||0.0||64 bits||1.23456e300d, -1.23456e-300d, 1e1d|
Values of type boolean are not converted implicitly or explicitly (with casts) to any other type. But the programmer can easily write conversion code:
final int i = b?1:0; final double d = b?1.0:0.0; final boolean b = i>0?true:false;
The 16-bit Unicode character set underlies both the Java source program and char data type. So, not only are Java programs written in Unicode characters, but Java programs can manipulate Unicode data.
|byte||8 bits||-128 .. 127|
|short||16 bits||-32,768 .. 32,767|
|int||32 bits||-2,147,483,648 .. 2,147,483,647|
|long||64 bits||-9,223,372,036,854,775,808 .. 9,223,372,036,854,775,807|
|float||32 bits||3.40282347 x 1038, 1.40239846 x 10-45|
|double||64 bits||1.7976931348623157 x 10308, 4.9406564584124654 x 10-324|
If you like dEexams.com and would like to contribute, you can also write your article here or mail your article to firstname.lastname@example.org . See your article appearing on the dEexams.com main page and help others to learn.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.