JAVA 应用程序的入口是 main 方法, 你在这个方法里什么都没有写,当然没有结果了

解决方案 »

  1.   

    但我在main()方法里调用test()方法,编译出错"不能引用非静态方法",不知老兄有何高招?main()是入口,出口是什么??
      

  2.   

    在main 函数里面ExceptionTest et = new ExceptionTest();
    et.test();
      

  3.   

    new ExceptionTest().test()
    这条语句写在什么位置?
    出口是什么 ?
      

  4.   

    new ExceptionTest().test()相当与
    ExceptionTest et =new ExceptionTest().test()
    et.test()你看看有关static属性和方法的描述就知道了
    import java.io.*;
    public class ExceptionTest
    {
      public static void main(String args[]){
       ExceptionTest et =new ExceptionTest().test()
       et.test()
      }
      public void ExcepionTest()
      {
        ExceptionTest et =new ExceptionTest();
        et.test ();
      }
      public void test()
      {
        int flag=1;
        try{
            FileReader fr=new FileReader("abcd.txt");
          }
        catch(FileNotFoundException e){
            System.out.println("文件未找到");
            flag=0;
          }
        finally{
            if (flag==1)
              {
                System.out.println ("文件找到");
              }
          }
      }
    }
      

  5.   

    你至少要在main函数里new一个实例!
      

  6.   

    建议:
    public void ExcepionTest()
      {
        ExceptionTest et =new ExceptionTest();
        et.test ();
      }
    如果是构造函数,去掉void;如果不是构造函数,不要和类取相同名字。
      

  7.   

    要麼new 一個ExceptionTest實例,然後用實例調用test方法.
    要麼把test方法改為static.建議老兄看看基本概念.