private variable reference problem

 1 public class Scope{
 2 private int i;
 3 public static void main(String argv[]){
 4                 Scope s = new Scope();
 5             s.amethod();
 6         }//End of main
 7         public static void amethod(){
 8                  System.out.println(i);
 9         }//end of amethod
10 }//End of class

Compile error, can not reference non-static variable in a static method.

Guess you like

Origin www.cnblogs.com/yz123/p/11956472.html