Results 1 to 5 of 5
  1. #1
    asif ali is offline Member
    Join Date
    Feb 2012
    Posts
    2
    Rep Power
    0

    Default 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 10:41 PM.

  2. #2
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default 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.

  3. #3
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default 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.

  4. #4
    rokit boy is offline Member
    Join Date
    Feb 2012
    Posts
    35
    Rep Power
    0

    Default Re: i have a problem in this code any one voluntier.

    Are you sure you imported stuff you need?

  5. #5
    asif ali is offline Member
    Join Date
    Feb 2012
    Posts
    2
    Rep Power
    0

    Default Re: i have a problem in this code any one voluntier.

    thanx j2me64 so much.

Similar Threads

  1. Problem with code
    By koryvandell in forum New To Java
    Replies: 4
    Last Post: 04-25-2011, 05:28 AM
  2. GUI code problem
    By baf06 in forum New To Java
    Replies: 17
    Last Post: 04-07-2011, 04:46 PM
  3. Replies: 0
    Last Post: 02-21-2011, 12:50 PM
  4. Replies: 9
    Last Post: 09-21-2010, 05:15 PM
  5. Problem my code..
    By Miyaki in forum New To Java
    Replies: 3
    Last Post: 03-09-2009, 01:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •