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

Similar Programs Chapter Last Updated
Java String Example Program Data Types 19-06-2016
Enum In Java Example Data Types 28-04-2016
Java Short Example Program Data Types 10-06-2016
Java Long Example Program Data Types 15-07-2016
Java Int Example Program Data Types 06-07-2016
Int Array In Java Example Program Data Types 09-06-2016
Java Float Program Example Data Types 28-03-2017
Java Double Example Program Data Types 28-03-2017
Java Char Example Program Data Types 28-03-2017
Java Byte Example Program Data Types 28-03-2017
Java Boolean Example Program Data Types 28-03-2017

1