|
#1
|
|||
|
|||
|
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 11:35 AM. |
|
#2
|
|||
|
|||
|
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
|
|||
|
|||
|
Check top post is the solution of overridding equal
Last edited by tking88; 10-24-2009 at 11:35 AM. |
|
#4
|
|||
|
|||
|
How do you compare String objects? You cannot use "==". There is a method of the String class which compares one String with another.
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Getting a GUI to run | Eric | Java | 4 | 04-14-2006 10:09 AM |
| Getting a GUI to function | Eric | Java | 1 | 11-27-2001 07:53 AM |
| Passing Data to another instance of an application | Michael Lambino | VB Classic | 12 | 06-14-2001 03:19 PM |
| Significance of System.EventArgs? | Paul Mc | .NET | 5 | 06-06-2001 06:10 PM |
| using the "this" method in a constructor | Mike | Java | 3 | 04-13-2001 10:13 PM |