在main函数内只能调用类静态的方法。
所以要改成
public static void calculate (){
}
public static void input (int number){}表明是类的全局成员。

解决方案 »

  1.   

    static 里面只能用 static 的东西
      

  2.   

    或者实例化一个对象之后,采用“对象.方法”的格式来访问方法可以在main()方法中这样写
    public static void main(String [] args)
    {
        test t=new test();
        t.input();
        t.calculate();
    }
      

  3.   

    慢慢学就是了,先看些java的基础,边看基础边看程序,那样效果好点,直接就看程序,肯定不行的
      

  4.   

    非static类型的属性或方法必须要在实例化之后才能调用,static类型的则可以直接使用而不用实例化。
      

  5.   

    先声明本类的一个实例,然后在main() 方法里调用对应的方法
      

  6.   

    import java.io.*;public class test16
    {
       private int number,n;
       
       public void input (int number)
       {
           System.out.println("Please input a number:");
           //this.number = System.in.read();
           this.number = number;
       }
       
       public void calculate ()
       {
           n = number * number;
           
           for(int i = 1;i <= n;i++)
           {
              if (n % i == 0)
              System.out.println(i);
           }
       }
       
       public static void main (String arg[])
       {
        test16 mytest = new test16();
          mytest.input(8);
           mytest.calculate();
       }
    }===========================================================
    import java.io.*;public class test16
    {
       private int number,n;
       
       public void input ()
       {
           System.out.println("Please input a number:");
           this.number = System.in.read();
           //this.number = number;
       }
       
       public void calculate ()
       {
           n = number * number;
           
           for(int i = 1;i <= n;i++)
           {
              if (n % i == 0)
              System.out.println(i);
           }
       }
       
       public static void main (String arg[]) throws IOException
       {
        test16 mytest = new test16();
          mytest.input();
           mytest.calculate();
       }
    }第一个程序可以运行,
    第二个不可以,错误是:
    test16.java:10: unreported exception java.io.IOException; must be caught or declared to be thrown this.number = System.in.read();
      

  7.   

    public static void main(String[] args){}
    含义是为了测试这个类`你里面没有这个类的对象`怎么可以运行呢`
      

  8.   

    是说JAVA里MAIN方法必须是STATIC对吧~那他里就不能直接调用本类的非STATIC方法了。
    然后程序的IO操作还都得有TRYCATCH对吧?还有问题是NUMBER这些要改变的变量不能是STATIC的在MAIN中出现的话,方法还得用对像。变量……好烦啊JAVA那么多事~~用惯了C语言和C++的程序,写JAVA程序老错~~其实这些规矩我都看过了在书上,就是一写就忘
      

  9.   

    怎么还错呢?加了try catch 了呀(我是菜菜^^)
    import java.io.*;public class test
    {
       private int number,n;
       
       public void input ()
       {
           System.out.println("Please input a number:");
           try{System.in.read();}
           catch(Exception e){}
           this.number = System.in.read();
           
       }
       
       public void calculate ()
       {
           n = number * number;
           
           for(int i = 1;i <= n;i++)
           {
              if (n % i == 0)
              System.out.println(i);
           }
       }
       
       public static void main (String arg[]) throws IOException
       {
        test mytest = new test();
          mytest.input();
           mytest.calculate();
       }
    }
      

  10.   

    import java.io.*;public class test
    {
       private int number,n;
       
       public void input ()
       {
           System.out.println("Please input a number:");
           try
           {
            System.in.read();
            this.number = System.in.read();
            }
           
           catch(Exception e){System.out.println(e)}
           
       }
       
       public void calculate ()
       {
          n = number * number;
          
          for(int i = 1;i <= n;i++)
          {
            if (n % i == 0)
            System.out.println(i);
          }
       }
       
       public static void main (String arg[]) throws IOException
       {
       test mytest = new test();
         mytest.input();
          mytest.calculate();
       }
    }可能产生异常的代码都要放到try{}里面
      

  11.   

    import java.io.*;public class test
    {
       private int number,n;
       
       public void input ()
       {
           System.out.println("Please input a number:");
           try
           {
            System.in.read();
            this.number = System.in.read();
            }
           
           catch(Exception e){System.out.println(e)}
           
       }
       
       public void calculate ()
       {
          n = number * number;
          
          for(int i = 1;i <= n;i++)
          {
            if (n % i == 0)
            System.out.println(i);
          }
       }
       
       public static void main (String arg[]) throws IOException
       {
       test mytest = new test();
         mytest.input();
          mytest.calculate();
       }
    }
    这样读的数字是他的ascii码,比如输入8它当作56来计算,要表达本来的意思应该怎么做呢?
      

  12.   

    this.number = System.in.read();更正
    read()函数用法不正确。
      

  13.   

    import java.io.*;public class test
    {
       private int number,n;
       
       public void input ()
       {
           System.out.print("Please input a number:");
           try
           {
           BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
    this.number = Integer.parseInt( buf.readLine());
            }
           
           catch(Exception e){System.out.println(e);}
           
       }
       
       public void calculate ()
       {
          n = number * number;
          
          for(int i = 1;i <= n;i++)
          {
            if (n % i == 0)
            System.out.println(i);
          }
       }
       
       public static void main (String arg[]) throws IOException
       {
       test mytest = new test();
         mytest.input();
          mytest.calculate();
       }
    }
      

  14.   

    public static void main (String arg[])
       {
    test mt=new test();
          mt.input(number);
          mt.calculate();
       }
    }
      

  15.   

    cacacy(卡卡西):
    非static类型的属性或方法必须要在实例化之后才能调用,static类型的则可以直接使用而不用实例化。这个是正解。