static是优先于对象存在,在内存中怎么表现的
class Person
{
static int a;
static int b;
public Person(int a,int b)
{
this.a=a;
this.b=b;
}
public Person(int b)
{
this.b=b;
}
public void show()
{
System.out.println(a+","+b);
}
}
class question
{
public static void main(String[] args)
{
Person s=new Person(1,2);
s.show();//1/2
s.b=4;
s.show();//1/4
Person s2=new Person(2,5);
s.show();//2/5
s2.show();//2/5
}
S.show() 为啥等于(2,5) |
|