ArrayListExample1.java
package java8s;
import java.util.*;
public class ArrayListExample1 {
public static void main(String[] args) {
List al = new ArrayList<String>();
al.add("First");
al.add("Second");
al.add("Third");
al.add("Fourth");
al.add("Fivth");
String[] s1 = new String[al.size()];
al.toArray(s1);
for(String s2 : s1)
System.out.println(s2);
}
}
Output:
First
Second
Third
Fourth
Fivth
No comments:
Post a Comment