static方法只能访问static属性,
以上定义了static main()方法,要直接访问访问成员属性的话只能将该属性声明为static。
要么你再编个方法间接调用该属性。

解决方案 »

  1.   

    static是类实例化之前就存在的方法,看你怎么用了,比如你用一个User类,他可以update,remove等等方法,自然从create方法就要定义成static方法了,它在你实例化之前就应该存在,同时,create方法中调用的变量也应该在实例化之前就存在了,所以应该是static
      

  2.   

    static方法只能访问static数据成员,
    如:static int a = 10;
    public static show(){
        System.out.println(a);
    }
    或者
    public static show(){
        int a = 10;    
        System.out.println(a);
    }