java common data types
Public static void main(String[] args){
short a=1;
int b=10;
long c=10000000L;//如果要表示long的直接量,需要以L或者l结尾,否则会出现编译错误
float f1=3.14f;//float类型和long相同,要表示float的直接量,需要以F或f结尾,否则会出现编译错误
double f2=2.68;
char s='你'; //注意char字符的储存空间,如果为“你好”则报错;因为char储存的是字符不是字符串所以用单引号
char s1='a';
boolean flag=true;
boolean close=false;
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(f1);
System.out.println(f2);
System.out.println(s);
System.out.println(s1);
System.out.println(flag);
System.out.println(close);
}
Output: