InterviewSolution
Saved Bookmarks
| 1. |
How To Convert Array To Arraylist In Java? |
|
Answer» Arrays class contains a STATIC factory method asList() that allows arrays to be VIEWED as LISTS. public static <T> List<T> asList(T... a) As Exp. String cityArray[] = {"Delhi", "Mumbai", "Bangalore", "Hyderabad", "CHENNAI"}; //Converting array to List List<String> cityList = Arrays.asList(cityArray); Arrays class contains a static factory method asList() that allows arrays to be viewed as lists. public static <T> List<T> asList(T... a) As Exp. String cityArray[] = {"Delhi", "Mumbai", "Bangalore", "Hyderabad", "Chennai"}; //Converting array to List List<String> cityList = Arrays.asList(cityArray); |
|