Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Comparable interface java 1.5

 
Cathy Song
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Could someone please post an example of how
to use the comparable interface with java 1.5?

Thank you.
-Cathy.
 
Jeff Langr
author
Ranch Hand
Posts: 799
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




Since you bind the interface to the Employee type, the compareTo method signature takes an argument of type Employee.

-Jeff-
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't dabbled with Java 5.0 yet, so I have a question related to this thread: can you implement Comparable "bound" to different types? I imagine something like:

Does this work? (I should probably download Java 5.0 and try it myself. However, I don't want to mess up my development environment at home while I'm in the middle of a big project. I'll definitely look into it next semester, though.)

Layne
 
Cathy Song
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Layne and Jeff

-Cathy.
 
Jeff Langr
author
Ranch Hand
Posts: 799
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome!

Layne --

The compiler appears to prevent it.

-Jeff-
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic