Skip to content

Data Types

Primitive data types in Java with examples.

package DSA.Basics;
public class datatypes {
public static void main(String[] args) {
byte b = 8;// 1 byte data type
System.out.println(b);
char ch = 'a';// stores single charecter
System.out.println(ch);
boolean var = true;// stores only true and false
float price = 10.5f;// store values with decimal values
long lo = 123456789123456789L;// stores long integer values
double eo = 3.145678925820625698855D;// stores long decimal values
short n = 240;// stores 2 byte integer values
System.out.println(n + " " + lo + " " + eo + " " + price + " " + var);
}
}