Previous | Home | Next |
Data type is a type variable will hold the value is called the Data Type. Java support primitive data types These are byte, int, short, long, char, float, double, and Boolean.
Data Type | Size in Bytes | Size in Bit | Value |
byte | 1 | 8 | Signed Integer (rang from -128 to 127) |
short | 2 | 16 | Signed/Unsigned Integer(rang from -32768 to 32767) |
integer | 4 | 32 | Signed/Unsigned Inegert(range from -2,147,483,648 to 2,147,483,647) |
long | 8 | 64 | Signed / Unsigned integer(range from -922337203685477580810 to 9223372036854775807) |
char | 2 | 16 | unicode character |
float | 4 | 32 | real number/floating number |
double | 8 | 64 | real number/floating number |
boolean | 1 | 8 | true/false |
//example write a program sum of two number public class Sum { public static void main(String[] args) { System.out.println("Addition of two numbers!"); int a = 5; int b =10; int c = a + b; System.out.println("Sum: " +c); } }
In above example has two variables of int data type which are used and store the numbers ,the result will also store in int data type.
The output of the above example is integer value i.e 15
Previous | Home | Next |