The java.util.Arrays.asList
returns a fixed-size list that is backed by the specified array; the returned list is serializable and allows random access.
The function declaration of the Arrays.asList()
:
The code snippet below illustrates the usage of the asList()
function:
import java.util.Arrays;import java.util.List;class AsList_Demo {public static void main (String args[]) {// create an array of stringsString fruits[] = new String[]{"Apple","Mango","Kiwi","Banana"};List l = Arrays.asList(fruits);// output listSystem.out.println("Fruits: " + l);}}
Free Resources