import java.io.*;public class io{

     BufferedReader Input=new BufferedReader(new InputStreamReader(System.in));
    //数据流进行输入     public static void main(String argc[]){
              String str;
     str = Input.readLine();//读取行。error: 无法从静态上下文中引用非静态 变量 str ????
     System.out.println(str);
}
}

解决方案 »

  1.   

    import java.io.*;public class io{

         static BufferedReader Input=new BufferedReader(new InputStreamReader(System.in));
        //数据流进行输入     public static void main(String argc[]){
                  String str;
         str = Input.readLine();//读取行。error: 无法从静态上下文中引用非静态 变量 str ????
         System.out.println(str);
    }
    }
    很显然main是static的
      

  2.   

    1.在static 方法中调用 类的non-static成员数据或成员函数,必须生成对象。
    non-static成员数据或成员函数属于对象,不属于类。2.当然你也可以把BufferedReader Input 数据成员声明成static。
      

  3.   

    静态上下文中只能使用静态变量,main是静态方法所以只能使用静态的变量,可以把程序改为如下:import java.io.*;public class io{
     public static void main(String argc[]) throws IOException {
          BufferedReader Input=new BufferedReader(new InputStreamReader(System.in));
        //数据流进行输入
           String  str = Input.readLine();//读取行。error: 无法从静态上下文中引用非静态 变量 str ????
         System.out.println(str);
    }
    }