package ch07;

public class Ch0702
{
 public static String message;
 
 //static 멤버함수에는 멤버변수에 직접 접근할수 없다.
 //그러나 static멤버변수에는 아래와 같이 접근가능함
 public static void print()
 {
  message ="Message";
  System.out.println(message);
 
  //sayHello();
  //static 멤버함수에서는 멤버함수를 호출 할 수 없다.
 }

 public void sayHello() {}
 
 public static void main(String[] args)
 {
  //static 멤버변수와 마찬가지로 클래스이름.멤버함수로 호출 가능
   Ch0702.print();
   //main 또한 같은 static 멤버함수이므로
   //위의 static 멤버함수호출을 직접 호출할수 있다.
   print();
 
  //sayHello();
 }
}

Posted by 말없제이
,