使用例。
public class DataTypeTest{
public static void main(String[] args){
byte b = 1;
short s = 2;
int i = 3;
long l = 4L;
float f = (float)1.1;
double d = 2.2;
char c = 'C';
boolean x = true;
System.out.println("byte b = " + b);
System.out.println("short s = " + s);
System.out.println("int i = " + i);
System.out.println("long l = " + l);
System.out.println("float f = " + f);
System.out.println("double d = " + d);
System.out.println("char c = " + c);
System.out.println("boolean x = " + x);
}
}
実行結果
byte b = 1
short s = 2
int i = 3
long l = 4
float f = 1.1
double d = 2.2
char c = C
boolean x = true