What is Instance, Empty Constructor ....


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: What is Instance, Empty Constructor ....

  1. #1
    Join Date
    Oct 2009
    Posts
    8

    What is Instance, Empty Constructor ....

    K I did something like this and all ok now it return the true compare value

    Code:
    public boolean equals(Object o)
    {
    System.out.println(o instanceof Moof);
    System.out.println(((Moof)o).getMoofValue());
    System.out.println(this.moofValue); //XXX
    if ((o instanceof Moof) && (((Moof)o).getMoofValue() == this.moofValue))
    {
    return true;
    }
    else
    {
    return false;
    }
    Last edited by tking88; 10-24-2009 at 10:35 AM.

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    Have you overridden the "equals" method of Object to allow your teacher instances to compare themselves? The instances are not the same and that is what the "equals" method is returning to you. YOu must define the state of your objects.

  3. #3
    Join Date
    Oct 2009
    Posts
    8
    Check top post is the solution of overridding equal
    Last edited by tking88; 10-24-2009 at 10:35 AM.

  4. #4
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    How do you compare String objects? You cannot use "==". There is a method of the String class which compares one String with another.

Similar Threads

  1. Getting a GUI to run
    By Eric in forum Java
    Replies: 4
    Last Post: 04-14-2006, 09:09 AM
  2. Getting a GUI to function
    By Eric in forum Java
    Replies: 1
    Last Post: 11-27-2001, 06:53 AM
  3. Passing Data to another instance of an application
    By Michael Lambino in forum VB Classic
    Replies: 12
    Last Post: 06-14-2001, 02:19 PM
  4. Significance of System.EventArgs?
    By Paul Mc in forum .NET
    Replies: 5
    Last Post: 06-06-2001, 05:10 PM
  5. Replies: 3
    Last Post: 04-13-2001, 09: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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center