chavez james wrote:the above code is not running, i am getting these errors.
Tester.java:32: error: cannot find symbol
return radius * 2;
^
symbol: variable radius
chavez james wrote:
location: class Tester.Circle
Tester.java:38: error: non-static variable this cannot be referenced from a static context
Circle cirl = new Circle (35.5);
^
Who on earth told you that sort of rubbish?chavez james wrote: . . . i am supposed to keep public class radius because it allows radius to be used in other methods.
. . .
I hope that advice isn't typical of the book. Otherwise you have wasted however much you paid for it.chavez james wrote: . . . book and the instructions are to use a public variable so it is available to all the methods in one single class. . . .
Henry Wong wrote: And inner class instances require an instance of the outer class to exist. The main method is in the outer class class, but it is a static method -- and static content does not have an outer class instance (via the this reference) ... hence, the error message.
Campbell Ritchie wrote:It says to add a method called diameter. I think it should really be called getDiameter, but you will have to do what the exercise tells you.
Then add the diameter method, which presumably returns the diameter of your circle. It should be simple to implement. You managed an area method (which should be called getArea)...
wbrehaut
Dee Hicks wrote:Can anyone explain to me the line "Circle.cir1=new Circle(35.5);"?
Consider Paul's rocket mass heater. |