来源 mars
(1)
写一个main函数,声明布尔型变量,打印。
public class exe1{
public static void main(String arg[]){
boolean b=false;
system.out.println(b);
boolean a=true; //只能是true和false不能是0
system.out.println(a);
}
}
(2)
在函数中创建char类型变量,并为其赋值
public class exe2{
public static void main(String args[]){
char c='a';
System.out.println(a);
}
}
(3)
每一种数值类型进行定义,并操作;
整数字面量为整型,小数字面量为双精度浮点型;
大范围赋值给小范围数值类型可能损失精度;
运算中的不同类型数值计算的结果的数值类型是计算的数值中表述范围最大的数值类型;
public class exe3{
public static void main(String args[]){
byte b=0;
short s=0;
int i=0;
long l=1;
float f=0;
double e=0;
System.out.println(l);
}
}