一个简单JAVA类,一直报错,郁闷!请大家帮助解答,谢谢
有个问题可以解答么?
package untitled3;
public class AAA {
public AAA() {
System.out.println("u1u");
}
int v;
private static AAA a;
public static AAA method() {
if (a == null) {
a = new AAA();
return a;
}
return null;
}
public int getValue() {
return v;
}
public void setValue(int v1) {
if(v1!=0){
this.v = v1;}
else{
this.v=0;
}
}
public static void main(String[] args) {
AAA t1 = AAA.method();
AAA t2 = AAA.method();
t2.setValue(23);
System.out.println(t1.v == t2.v);
}
}
为什么一直报错呢,谢谢