This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes Comparable Interface Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Comparable Interface" Watch "Comparable Interface" New topic
Author

Comparable Interface

rahulJ james
Ranch Hand

Joined: Oct 03, 2008
Posts: 123
I am writing a program to get the numbers from the user and get that sorted based on ODD or EVEN numbers. I am using a list to store the numbers from user and I could sort it. Can I do the same by using Comparable Interface. If Yes, can someone helo in this..

Sridhar Santhanakrishnan
Ranch Hand

Joined: Mar 20, 2007
Posts: 317
Check out Collections.sort()
rahulJ james
Ranch Hand

Joined: Oct 03, 2008
Posts: 123
This doesnt give me a proper order.. Again it sorts by its own way..
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Really? Because if I use your code and then print out the two arrays, I get two sorted arrays - with leading zeros for all non-set elements of course.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Comparable Interface
 
Similar Threads
how to solve this type of stackoverflowerror...
accepting user input into into an array
LinkedHashMap - trying to use the method removeEldestEntry
Main not found, but it exists!
Need help with using Greek letters read in from file