C:\Tomcat 4.1\webapps\ROOT\WEB-INF\classes>javac News.java
News.java:42: non-static variable htInfo cannot be referenced from a static context
                htInfo.put("vcTitle",title);
                ^
1 error

解决方案 »

  1.   

    第一:
    Hashtable htInfo  //数组信息public void News(){
       htInfo  = new Hashtable();
    }
    第二:
    public static void main(String args[]) {
        News  _new = new News();
        _new.setTitle("title");
        System.out.println("aa");
    }
      

  2.   

    kao!
    强!
    同时觉得自弱
      

  3.   

    public class News {
    Hashtable htInfo=null;
             News(){
                    htInfo  = new Hashtable();
    }
    //设定标题
    public void setTitle(String title){
    htInfo.put("vcTitle",title);
    }
    //设定内容
    public void setContent(String Content){
    htInfo.put("txContent",Content);
    }
    //添加操作
    public void add(){
    String sql = "";

    }
    public static void main(String args[]) {
    News  news = new News();
                      news.setTitle("title");
    System.out.println("aa");
    }
    }