File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes index question-arraylist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "index question-arraylist" Watch "index question-arraylist" New topic

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();
ArrayList<String> al = new ArrayList<String>();
for(String element : al){

Answer is dcz ..please explain
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2398
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: 2398
Oops I mean Collections.sort
I agree. Here's the link:
subject: index question-arraylist
It's not a secret anymore!