Primitive Datatypes In Java Example
Chapter:
Data Types
Last Updated:
17-06-2016 03:29:12 UTC
Program:
/* ............... START ............... */
public class JavaPrimitiveDataTypesExample {
public static void main(String[] args) {
byte b = 98;
short s = 120;
int v = 13454;
int calc = -3555;
long amountVal = 123456789;
float intrestRate = 10.33f;
double sineVal = 12345.234d;
boolean flag = true;
boolean val = false;
char ch1 = 88; // code for X
char ch2 = 'A';
System.out.println("byte Value = " + b);
System.out.println("short Value = " + s);
System.out.println("int Value = " + v);
System.out.println("int second Value = " + calc);
System.out.println("long Value = " + amountVal);
System.out.println("float Value = " + intrestRate);
System.out.println("double Value = " + sineVal);
System.out.println("boolean Value = " + flag);
System.out.println("boolean Value = " + val);
System.out.println("char Value = " + ch1);
System.out.println("char Value = " + ch2);
}
}
/* ............... END ............... */
Output
byte Value = 98
short Value = 120
int Value = 13454
int second Value = -3555
long Value = 123456789
float Value = 10.33
double Value = 12345.234
boolean Value = true
boolean Value = false
char Value = X
char Value = A
Notes:
-
There are eight primitive data types supported by Java.
Tags
Primitive Datatypes, Java, Data Types