![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Oct 2006
Posts: 25
Rep Power: 0
![]() |
Generic type + equals() method
I'm doing a program for my Data Structures class but I've ran into a little problem with my code that I can't seem to figure out. I have to override the toString(), equals(), and compareTo() methods all with generic type and I have everything working except equals().
public boolean equals(T other)
{
Customer eOther = (Customer)other;
if(id.equals(eOther.id))
{
return true;
}
else
{
return false;
}
} |
|
|
|
|
|
#2 |
|
Expert Programmer
|
Re: Generic type + equals() method
public boolean equals(Object obj) {
if (!(object instanceof Customer))
return false;
Customer cust = (Customer)obj;
// determine if cust is equal to this
...
} |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Oct 2006
Posts: 25
Rep Power: 0
![]() |
Re: Generic type + equals() method
Thanks
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Method not returning string | csrocker101 | C# | 1 | Apr 6th, 2007 6:45 PM |
| How to invoke static method from a Class object? | smith.norton | Java | 1 | Oct 5th, 2006 3:00 AM |
| Arrays with Generic Type | azurik | Java | 6 | Jun 14th, 2006 12:31 PM |
| Pointer return type,.. ??? | Mack1982 | C++ | 28 | May 26th, 2006 8:02 PM |
| Debug recursion method() | pr0gm3r | Java | 3 | Oct 11th, 2005 12:33 PM |