lizhihua
发贴: 8
积分: 0
|
于 2005-10-01 23:23
在调用Circle类中的getperimeter(),这个方法时应该是用对象来调用的。 你的代码中调用这个方法时写的是这样的[Circle circle = new Circle();circle是这个类的对象〕而你写的是类在调用这个方法Circle.getperimeter, 应该是用这个类对象调用(circle.getperimeter())还有就是花括号或多或少,以下是正确的代码。 class yuan { public static void main(String args[]) { Circle circle=new Circle(1.00,2.00,3.00); System.out.println("圆的周长是:"+circle.getPerimeter()); } } class Circle { double x=0; double y=0; double r=0; final double PI=3.1415926; public double getPerimeter() { return(PI*PI*r); } public Circle(double xx,double yy,double rr) { x=xx; y=yy; r=rr; } } 我们共同努力!!!!!加油!!!!!
|