java 让几个类共享同一个对象,菜鸟看不出共享体现在那
publicclassmain3{publicstaticvoidmain(String[]args){Aa=newA();System.out.println("say...
public class main3
{
public static void main(String[] args)
{
A a=new A();
System.out.println("say1"+a.getC());
}
}
class C{}
class A{
private C c = null;
public C getC(){
return this.c;
}
public void setC(C cc){
this.c = cc;
System.out.println("say3"+c);
}
} 展开
{
public static void main(String[] args)
{
A a=new A();
System.out.println("say1"+a.getC());
}
}
class C{}
class A{
private C c = null;
public C getC(){
return this.c;
}
public void setC(C cc){
this.c = cc;
System.out.println("say3"+c);
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询