String Array to ArrayList Example
String Array to ArrayList example. This example shows you how to Convert string array to an ArrayList.
This example shows you how to Convert string array to an ArrayList.
Here is the code
/**
* @ # StringArray1.java
* A class repersenting how Convert
* string array to an ArrayList
* version 04 June 2008
* author Rose India
*/
import java.util.*;
public class StringArray1 {
public static void main(String args[]) {
String arr[] = {"Zero", "One", "Two"};
//Convert string array to an ArrayList
List l = Arrays.asList(arr);
ArrayList list = new ArrayList(l);
System.out.println("list = " + list);
}
} |
|