1Integer[] spam = new Integer[] { 1, 2, 3 };
2List<Integer> list = Arrays.asList(spam);
1/*
2Get the Array to be converted.
3Create the List by passing the Array as parameter in the constructor of the List with the help of Arrays. asList() method.
4Return the formed List.
5*/
6
7String[] namedata = { "ram", "shyam", "balram" };
8
9List<String> list = Arrays.asList(namedata);
1String[] myArray = new String[] { "I", "like", "eating", "pizza" };
2List<String> myList = Arrays.asList(myArray);
3
4myList.forEach(string -> System.out.println(string));
5
6// -output-
7// I
8// like
9// eating
10// pizza
11// -output-