Java中基本数据类型的默认值(初始值),
数据类型
默认值
byte
0
short
0
int
0
long
0
float
0.0
double
0.0
String
null
boolean
false
public class bdtdValues {
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("String类型的初始值为" + v.str);
System.out.println("boolean类型的初始值为" + v.flag);
}
}
class Variable {
byte byteNum;
short shortNum;
int intNum;
long longNum;
float floatNum;
double doubleNum;
String str;
boolean flag;
}
byte类型的初始值为0
short类型的初始值为0
int类型的初始值为0
long类型的初始值为0
float类型的初始值为0.0
double类型的初始值为0.0
String类型的初始值为null
boolean类型的初始值为false
http://www.dengb.com/Javabc/1397542.htmlwww.dengb.comtruehttp://www.dengb.com/Javabc/1397542.htmlTechArticleJava中基本数据类型的默认值(初始值), 数据类型 默认值 byte 0 short 0 int 0 long 0 float 0.0 double 0.0 String null boolean false public class bdtdValues { publ...