类的成员变量不是不需要赋值,而是会自动初始化。
boolean false
char ‘\u0000’(null)
byte (byte)0
short (short)0
int 0
long 0L
float 0.0f
double 0.0d
String null
//char的默认值
package test;
public class test {
static char ch;
public static void main(String arg[]) {
if(ch == ' ')
System.out.println(1);
if(ch == '\u0000')
System.out.println(2);
}
}
运行结果为:
2