Did you try googling for something like java compareTo example or java compareTo tutorial?
Jim Stevens wrote:I understand how it works. But i can't simply say 01<02. That does not work. How do I compare to object without using <>or =???
Then you don't really understand how it works.
Do the searches I suggested.
and in the sort method would i do if(compareTo(temp1,temp2) = -1??? thank you
No, it would be:
The compareTo method is called on one of the two objects you're comparing. And you can't just assume compareTo will return 1 for x < y, only that it will return something < 0.
Jim Stevens wrote:I have done the searches.
I can't imagine what I can tell you that's not there. If you don't show what you tried or tell us what part you didn't understand. Here's an example, but I'm sure similar examples would have been readily available in the search results.
Also, note that unless you're writing your own sort method, you'll never call compareTo directly. If you call Collections.sort(), it calls compareTo() on various pairs of values.