wood burning stoves 2.0*
The moose likes Java in General and the fly likes java problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "java problem" Watch "java problem" New topic

java problem

peterx peter

Joined: Nov 02, 2004
Posts: 19
Rusty Shackleford
Ranch Hand

Joined: Jan 03, 2006
Posts: 490
Emploee should implement the Comparable interface. Then in the compareTo method, you can write specific code to test for whatever field you are going to use to compare 2 objects. This is the way it is generally done.

Using TheSamaEmployer method will work, and is similar to using Comparable, but is not as self documenting.

Calling it is just like calling any other method. e.TheSamaEmployer(Some other Employee object reference).

You need to decide which member to use to test. SInce they are both Strings, you will use one of several String methods to compare them. If all you need is equals or not, then equals() or equalsIgnoreCase is the way to go. If you are going to need to sort them, the compareTo method in String is what you need.
[ September 06, 2006: Message edited by: Rusty Shackleford ]

"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
Srinivas Kalvala
Ranch Hand

Joined: Oct 20, 2005
Posts: 257

Originally posted by peterx peter:

Please visit , http://faq.javaranch.com/view?HowToAskQuestionsOnJavaRanch
I agree. Here's the link: http://aspose.com/file-tools
subject: java problem
Similar Threads
how to create insert, update, delete buttons on the same page?
Testing @ManyToOne Relationships
Simple inheritance example
JavaRanch Rule Round-up Game Query ??
Exception while firing the join queries