Data Types and Data Structures in Java


Primitive Data Types
When java stores data it does so by setting up space in the computer memory devices (RAM). Different types of data require different amounts of memory space (size) and are processed differently by the computer.
Java determines the size of each primitive type. These sizes do not change from one machine architecture to another (as do in most other languages). This is one of the key features of the language that makes Java so portable.
Take note that all numeric types are signed. (No unsigned types).


Primitive Type
Size
Minimum Value
Maximum Value
Wrapper Type
char
16-bit
Unicode 0
Unicode 216-1
Character
byte
8-bit
-128
+127
Byte
short
16-bit
-215
(-32,768)
+215-1
(32,767)
Short
int
32-bit
-231
(-2,147,483,648)
+231-1
(2,147,483,647)
Integer
long
64-bit
-263
(-9,223,372,036,854,775,808)
+263-1
(9,223,372,036,854,775,807)
Long
float
32-bit
32-bit IEEE 754 floating-point numbers
Float
double
64-bit
64-bit IEEE 754 floating-point numbers
Double
boolean
1-bit
true or false
Boolean






declaring (setting up) primitive variables in the java language
int i = 16;byte bt = 123;short s = 77;long l = 12345L;float f = 1.48F;double d = 2.7e-123;char c = 'h';boolean b = true;



Finally, notice that each primitive data type also has a "wrapper" class defined for it. This means that you can create a "nonprimitive object" (using the wrapper class) on the heap (just like any other object) to represent the particular primitive type.
  • For example:int i = 5; Integer I = new Integer(i);ORInteger I = new Integer(5);



Links
http://www.roseindia.net/java/master-java/java-data-types.shtml


http://introcs.cs.princeton.edu/java/12types/
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
http://www.tutorialspoint.com/java/java_basic_datatypes.htm
http://en.wikipedia.org/wiki/Floating_point
http://www.inf.unibz.it/~calvanese/teaching/ip/lecture-notes/uni04.pdf
http://en.wikipedia.org/wiki/Data_type



Strings



Arrays (they are classified as objects)



Objects