gudii9
asked on
treeset sort
TreeSet t=new TreeSet();
t.add("A");
t.add("Z");====>"Z".compar eTo("A");( positive) how much positive number it comes?
t.add("A");====>"A".compar eTo("B");( negative)/ /here while jvm doing default natural sorting i thought instead of B, Z has to be compared with A but B is being compared with A since B is root element. What is meaning of root element. why Z is not root element??
System.out.println(t)//com es [A,B,Z} right not [Z,B,A]
how to get custom sorting like Z B A
why StringBuffer does not support default natural sorting. How to sort String Buffer objects.
obj1.compareTo(obj2)//obj2 is already present element in tree set and obj1 is new element being added??
please advise
t.add("A");
t.add("Z");====>"Z".compar
t.add("A");====>"A".compar
System.out.println(t)//com
how to get custom sorting like Z B A
why StringBuffer does not support default natural sorting. How to sort String Buffer objects.
obj1.compareTo(obj2)//obj2
please advise
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.