글수 77
class static1
{
public static int x;
public int y;
}
--------------------------------
class static1Test
{
public static void main(String[] args)
{
static1 o1 = new static1();
static1 o2 = new static1();
o1.x=1;
o1.y=2;
o2.x=3;
o2.y=4;
System.out.printf("%d %d %d %dn",
o1.x,o1.y,o2.x,o2.y);
}
}
--------------------------------
3 2 3 4
계속하려면 아무 키나 누르십시오 . . .



class static2
{
public static int count=0;
public int y;
public static2(int y){
this.y=y;
count++;
}
}
-----------------------------------
class static1Test
{
public static void main(String[] args)
{
static2 o1 = new static2(2);
static2 o2 = new static2(3);
static2 o3 = new static2(34);
static2 o4 = new static2(34);
System.out.println(o1.count);
}
}
--------------------
4
계속하려면 아무 키나 누르십시오 . . .