A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© hjz564 中级黑马   /  2013-6-6 22:39  /  1001 人查看  /  4 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

代码有n处红点,应该怎么根据内容进行修复呢?Exception in thread "main" java.lang.Error: Unresolved compilation problem:
        The method addFactorial() is undefined for the type AppMain

        at AppMain.main(AppMain.java:5)


下面是含错误的代码,求解决
class NoValueException extends RuntimeException
interface Shape    //加上了Runtime
{
    void getArea();
       
}

class Rec implements Shape
{
        private int len , wid;
       
        Rec(int len ,int wid)//throws NoValueException
        {
                if(len<=0 || wid<=0)
                        throw new NoValueException("出现非法值");
                else
                {       
               
                this.len = len;
                this.wid = wid;
       
        }
   
        public void getArea{}
        {
                System.out.println(len*wid);
               
        }

}

class Circle  implements Shape
{
        private int radius;
        public static final double PI = 3.14;
       
        Circle(int radius)
        {
                if (radius<=0)
                        throw new RuntimeException("非法")
                this.radius = radius;
        }
       
        public void getArea()
        {
                System.out.println(radius*radius*PI);
        }
}

class ExceptionTest1
{
        public static void main(String[] args)
        {
               
                Rec r = new Rec(3,4);
            r.getArea();
            
            Circle c = new Circle(-8);
               
                System.out.println(e.toString());
               
        }
    System.out.println("over");
    cathc(*)
       
        }
}













评分

参与人数 1技术分 +1 收起 理由
苏波 + 1

查看全部评分

4 个回复

倒序浏览
我看了半天,没看出什么东西。
又在VS中运行了一下,才发现这是JAVA程序。
同学这里是.NET区,你问错地方了,请移步到JAVA区!
我花了十几分钟来看程序,能给加点技术分吗?
谢谢!
回复 使用道具 举报
class ExceptionTest1
{
         public static void main(String[] args)
         {
                 
                Rec r = new Rec(3,4);
             r.getArea();
            
             Circle c = new Circle(-8);
                 
                System.out.println(e.toString());
                 
        }
     System.out.println("over");
     cathc(*)
         
        }
}

cathc(*)这个是什么意思..求解?
回复 使用道具 举报
看到你两次了 {:soso_e144:} 你还是没回java
回复 使用道具 举报
晕,跑.net板块问。。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马