Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: whats wrong with code, please help me understand thanks

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default whats wrong with code, please help me understand thanks

    public class Rectangle {

    public Rectangle(int width, int height) {
    Rectangle x = new Rectangle(7, 9);
    double d = x.getDiagonal();
    System.out.println(d);



    }

    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,166
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: whats wrong with code, please help me understand thanks

    Please explain why you think there is something wrong.
    If you get error messages, copy the full text and paste it here.
    If wrong output, post the output and explain what is wrong with the output.

    Please edit your post and wrap your code with code tags:
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Sep 2013
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: whats wrong with code, please help me understand thanks

    it says the method getDiagonal is undefined for the type Rectangle

    --- Update ---

    it says the mehod getDiagonal() is undefined for the type Rectangle

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,166
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: whats wrong with code, please help me understand thanks

    Did you look in the API doc for the class Rectangle? Does it have a getDiagonal() method defined?

    See the API doc: Java Platform SE 7
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Sep 2013
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: whats wrong with code, please help me understand thanks

    it is in java.lang.object

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,166
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: whats wrong with code, please help me understand thanks

    it is in java.lang.object
    What is that? A package or a class? Where are you seeing that in the documentation?

    Note: Java class names start with Uppercase letters. The correct spelling for the Object class starts with a capital O
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Sep 2013
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: whats wrong with code, please help me understand thanks

    Quote Originally Posted by Norm View Post
    What is that? A package or a class? Where are you seeing that in the documentation?

    Note: Java class names start with Uppercase letters. The correct spelling for the Object class starts with a capital O
    stop asking silly question s and help me if u can,....if you can't then leave the page

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,166
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: whats wrong with code, please help me understand thanks

    method getDiagonal is undefined for the type Rectangle
    You need to read the API doc for the Rectangle class and see what methods it has.
    The compiler is not finding the method: getDiagonal

    You must use methods that are defined for the class, you can not use undefined methods.

    What do you want the code to do? The volunteers are here to help you write your code and get it to work.
    We do not write code for you. Figure out what you want to do, write the code to do it and if you have problems with it, copy the code here and post your questions about the problems you are having.
    Be sure to copy and paste the full text of any error messages.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Whats wrong with my code?
    By mhphucld in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 26th, 2013, 08:50 PM
  2. hi if u can help me please whats wrong with this code
    By ohad in forum What's Wrong With My Code?
    Replies: 5
    Last Post: April 8th, 2013, 02:04 PM
  3. Please help to understand whats the wrong with my guess. - Simple program
    By rayan2004 in forum Object Oriented Programming
    Replies: 1
    Last Post: December 14th, 2012, 01:03 AM
  4. Can't seem to understand whats wrong with my code! Help!!
    By aquir in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 2nd, 2011, 12:06 PM
  5. Whats Wrong with this code?
    By whattheeff in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 9th, 2011, 10:59 PM