| Author |
index question-arraylist
|
pravin kumar
Ranch Hand
Joined: Nov 03, 2005
Posts: 30
|
|
What will happen when you attempt to compile and run the following code? import java.util.*; public class SortList{ public static void main(String argv[]){ new SortList(); } SortList(){ ArrayList<String> al = new ArrayList<String>(); al.add("z"); al.add("b"); al.add("c"); Collections.sort(al); for(String element : al){ System.out.print(element); } } } Answer is dcz ..please explain
|
 |
Keith Lynn
Ranch Hand
Joined: Feb 07, 2005
Posts: 2341
|
|
|
I assume you mean bcz. There is a method call Arrays.sort(al) that will sort the ArrayList.
|
 |
Keith Lynn
Ranch Hand
Joined: Feb 07, 2005
Posts: 2341
|
|
|
Oops I mean Collections.sort
|
 |
 |
|
|
subject: index question-arraylist
|
|
|