Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to iterate elements in TreeSet in java ?

TatonAug 28 2006 — edited Jan 23 2008
import java.util.*;
public class Drink implements Comparable {
public String name;

public int compareTo(Object o) {
return 0;
}
public static void main(String[] args)
{
Drink one = new Drink();
Drink two = new Drink();
one.name = "Coffee".
two.name = "Tea".
TreeSet set = new TreeSet();
set.add(one);
set.add(two);

} 
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 20 2008
Added on Aug 28 2006
15 comments
1,060 views