package ch07;
public class Ch0701
{
//static으로 선언된 멤버변수는 공유해서 사용.
public static String x;
public static int y;
//static 없음.. a.x => Hello a.y=10
//static 없음.. a.c => null c.y=0
//public
public static void main(String[] args)
{
// static으로 선언ㅇ된 멤버변수나 멤버함수는
// 아래의 경우처럼 생성된 개별인스턴스개체변수에 관계없이
// 그 값을 서로 공유하는 형태가 된다.
// (모든 자동차의 교통바송은 95.1주파수이다.)
// 특징: static으로 선언된 멤버변수나 멤버함수는
// 인스턴스를 생성하지 않고 클래스이름.멤버변수나
// 클래스이름.멤버함수() 형태로 직접 참조 및 호출 가능
Ch0701 a = new Ch0701();
a.x = "Hello";
a.y = 10;
Ch0701 b = new Ch0701();
b.x = "Message";
b.y = 100;
System.out.println("x : "+a.x+", y : "+a.y);
Ch0701 c = new Ch0701();
System.out.println("x : "+c.x+", y : "+c.y);
Ch0701.x = "static 놀랍지??";
Ch0701.y = 1004;
System.out.println("x : "+a.x+", y : "+a.y);
System.out.println("x : "+b.x+", y : "+b.y);
System.out.println("x : "+c.x+", y : "+c.y);
}
}