Chandrakant Talele

Greenhorn
+ Follow
since Dec 08, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Chandrakant Talele


You need to understand difference between Comparable and Comparator.

Comparable implementations provide a natural ordering for a class, which allows objects of that class to be sorted automatically.

Comparator is an object that encapsulates an ordering. You will use Comparator when you want to sort some objects in an order other than their natural ordering or when you want to sort some objects that don't implement Comparable.

Refer to http://download.oracle.com/javase/tutorial/collections/interfaces/order.html where this stuff is explained nicely.

In your case, Fruit is not required to implement Comparable. This should solve the problem
13 years ago

The class is right there in the same file (AbstractList.java), just search for "class SubList"
In my jdk1.6.0_16 it is at line 592
13 years ago
Oops , yes I interpreted the problem incorrectly, my apologies
Here is the sample program that will work. I hope I am correct this time.
I am running it in eclipse and "bin" is where my .class files are.



Thanks Campbell Ritchie for the welcome
15 years ago
Hi Rajshkhr Pandey,
Do you mean in following example, when you run Test2.main() it is not printing anything?


It works for me
15 years ago