package newqueastion;
public class NewQuestion {
byte b;
short s;
int i;
long l;
float f;
double d;
int[] arr=null;
int[] arr1;
boolean boo;
char c;
String str;
public boolean testMethon(){
return true;
}
}
package newqueastion;
public class Test {
public static void main(String[] args) {
//正确的实例化方式 打印true 0 null
NewQuestion c=new NewQuestion();
System.out.println(c.testMethon()+"\t");
//成员变量不写会有默认值
System.out.println("------默认值测试------");
//byte、short、int、long默认值为0
System.out.println(c.b);
System.out.println(c.s);
System.out.println(c.i);
System.out.println(c.l);
//float、double默认值为0.0
System.out.println(c.f);
System.out.println(c.d);
//数组默认null
System.out.println(c.arr);
System.out.println(c.arr1);
//boolean 为false
System.out.println(c.boo);
//char类型 \u0000
System.out.println(c.c);
//String类型 null
System.out.println(c.str);
}
}