数据类型 | 默认值 |
---|---|
byte | 0 |
short | 0 |
int | 0 |
long | 0 |
float | 0.0 |
double | 0.0 |
char | 'u0000' |
boolean | false |
public class demo1 {
public static void main(String[] args) {
Variable v = new Variable();
System.out.println("byte类型的初始值为" + v.byteNum);
System.out.println("short类型的初始值为" + v.shortNum);
System.out.println("int类型的初始值为" + v.intNum);
System.out.println("long类型的初始值为" + v.longNum);
System.out.println("float类型的初始值为" + v.floatNum);
System.out.println("double类型的初始值为" + v.doubleNum);
System.out.println("boolean类型的初始值为" + v.flag);
}
}
class Variable {
byte byteNum;
short shortNum;
int intNum;
long longNum;
float floatNum;
double doubleNum;
boolean flag;
}
byte类型的初始值为0
short类型的初始值为0
int类型的初始值为0
long类型的初始值为0
float类型的初始值为0.0
double类型的初始值为0.0
boolean类型的初始值为false