Results 1 to 5 of 5
- 02-07-2012, 09:38 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 2
- Rep Power
- 0
i have a problem in this code any one voluntier.
public class exercise {
public static void main(String[] args){
Circle myCircle = new Circle(5.0);
System.out.println("The area of the circle of radius "
+ myCircle.radius + " is " + myCircle.getArea());
}
class Circle{
double radius;
Circle(){
radius=1.0;
}
Circle(double newradius){
radius=newradius;
}
double getArea(){
return radius*radius*Math.PI;
}
}
}Last edited by asif ali; 02-07-2012 at 09:41 PM.
- 02-07-2012, 09:43 PM #2
Re: i have a problem in this code any one voluntier.
the class Circle is declared inside the class exercise. make sure that the class Circle is declared outside in its own file.
- 02-07-2012, 09:46 PM #3
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,546
- Rep Power
- 11
Re: i have a problem in this code any one voluntier.
What is the problem?
If there is a message from the compiler that you cannot understand, post that message and someone is sure to explain what it means.
- 02-07-2012, 10:24 PM #4
Member
- Join Date
- Feb 2012
- Posts
- 35
- Rep Power
- 0
Re: i have a problem in this code any one voluntier.
Are you sure you imported stuff you need?
- 02-08-2012, 04:17 AM #5
Member
- Join Date
- Feb 2012
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
Problem with code
By koryvandell in forum New To JavaReplies: 4Last Post: 04-25-2011, 04:28 AM -
GUI code problem
By baf06 in forum New To JavaReplies: 17Last Post: 04-07-2011, 03:46 PM -
C server code - Java CLient Code _ TCP Connection Problem
By rmd22 in forum NetworkingReplies: 0Last Post: 02-21-2011, 11:50 AM -
Can anyone see the problem with my code? problem understanding switch (newbish)
By keith in forum New To JavaReplies: 9Last Post: 09-21-2010, 04:15 PM -
Problem my code..
By Miyaki in forum New To JavaReplies: 3Last Post: 03-09-2009, 12:36 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks