简单理解一下……你写一个String a="";之类的不会出错的然后用自动生成框架会提示你是不是catch RuntimeException的。

解决方案 »

  1.   

    :(
    呵呵~~public class BaseRuntimeException extends RuntimeException

    ------------------------------
    public class test1
    {
       public void getname(boolean bb)
       {
        if (bb)
    {
    System.out.println("ok");
    }
    else
    {
    throw new BaseRuntimeException("error info!");
    }
       }
    }-------------------------------
    如何让Eclipse根据test.getname(),生成try...catch (BaseRuntimeException e)
    -------------------------------
        public void execname()
        {
         test1 test = new test1();
         try
    {
    test.getname(false);
    }
    catch (BaseRuntimeException e)
    {
    }
        }
    ---------------------------------
    如果test.getname()抛出的异常(BaseRuntimeException ),直接继承Exception,则eclispe可以提示,可是BaseRuntimeException 继承的是RuntimeException灯泡兄,你明白了码? ;(
      

  2.   

    理论上来说 是不可能的 
    你也太难为IDE了你没有显式的声明抛出异常,你让别人如何清楚?
      

  3.   

    一般来讲你不应该使用RuntimeException,如果用RuntimeException,那么意图可能就是为了免去每次throw,try{}catch(){}的麻烦,这你也太难为IDE了
      

  4.   

    RuntimeException的子类可多去了估计生成的代码会没法看的。
      

  5.   

    我明白你的意思的但是RuntimeException的子类的话你必须声明抛出throws BaseRuntimeException。eclipse才会在自动生成代码的时候知道这个异常。否则的话你现在的代码,生成的一定是: try {
    test.getname(false);
    } catch (RuntimeException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }