Results 1 to 3 of 3
  1. #1
    hamed is offline Member
    Join Date
    Sep 2010
    Posts
    11
    Rep Power
    0

    Default equals(object obj)

    Hi there.
    I don't understand the following Boolean:(plz some one explain it to me what it does.What is exactly onject and what does equals((point3)p ) do?)
    -------------------------------------------------------------
    public class Point3 extends Point2 {
    private int z;
    ...

    public boolean equals(Object p) { // overriding definition
    if (p instanceof Point3) return equals((Point3)p);
    return super.equals();
    }

    public boolean equals(Point2 p) { // overriding definition
    if (p instanceof Point3) return equals((Point3)p);
    return super.equals();
    }

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,574
    Rep Power
    23

    Default

    equals((point3)p )
    Casts p to type in () and calls the equals method with that type as an argument

    What happens when you execute the code? Add some print statements to show how the compiler matched the code to the method.

  3. #3
    hamed is offline Member
    Join Date
    Sep 2010
    Posts
    11
    Rep Power
    0

Similar Threads

  1. == and equals()
    By arefeh in forum New To Java
    Replies: 13
    Last Post: 01-05-2010, 04:56 PM
  2. == is same as .equals()??
    By DrMath in forum New To Java
    Replies: 1
    Last Post: 09-30-2009, 04:57 AM
  3. Object class's equals() method behavior????
    By skyineyes in forum New To Java
    Replies: 4
    Last Post: 07-19-2008, 11:58 PM
  4. Replies: 1
    Last Post: 04-17-2008, 10:10 PM
  5. Replies: 0
    Last Post: 01-25-2008, 11:13 PM

Posting Permissions

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