public class TestType {
byte s1;
short s2;
int s3;
long s4;
float s5;
double s6;
char s7;
boolean s8;
String s9;
public void print(){
System.out.println("byte:"+s1+" short:"+s2+" int:"+s3+" long:"+s4+" float:"+s5+" double:"+s6);
System.out.println("char:"+s7+" boolean:"+s8+" String:"+s9);
}
public static void main(String[] args){
TestType test=new TestType();
test.print();
}
byte s1;
short s2;
int s3;
long s4;
float s5;
double s6;
char s7;
boolean s8;
String s9;
public void print(){
System.out.println("byte:"+s1+" short:"+s2+" int:"+s3+" long:"+s4+" float:"+s5+" double:"+s6);
System.out.println("char:"+s7+" boolean:"+s8+" String:"+s9);
}
public static void main(String[] args){
TestType test=new TestType();
test.print();
}
}
输出结果:
byte:0 short:0 int:0 long:0 float:0.0 double:0.0
char:[]{\u0000}
boolean:false String:null
注意:局部变量【方法内声明的变量】必须手动初始化!!!