• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java problem

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 257
Hibernate Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by peterx peter:




Please visit , http://faq.javaranch.com/view?HowToAskQuestionsOnJavaRanch
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic