Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

Venkata Krishn Rao Maddu

Greenhorn
+ Follow
since Apr 02, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Venkata Krishn Rao Maddu

I dont know following will be the better choice or not but, I have tried in this way and it would give other numbers also if your input string contains numbers otherthan Id number.



use above method while iterating the string tokenizer


11 years ago
check the following example,

11 years ago
Comparable interface is having compareTo() method and which is normally used for natural ordering.
Comparator interface is having compare() method which takes two arguments and it can be used whenever you want to sort objects based of more then one parameter.

Example:

Comparable Interface:



Comparator Interface:

11 years ago