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

Chandrakant Talele

Greenhorn
+ Follow
since Dec 08, 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 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
10 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
10 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
11 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
11 years ago