Unlike arrays, we cannot initialize array lists directly. However, we can use the asList() method of the Arrays class to achieve the same effect. In order to use the asList() method, we must import the java.util.Arrays package first.
For example,
Output
In the above example, notice the expression,
Here, we have first created an array of 3 elements: "Cat", "Cow", and "Dog". Then, the asList() method is used to convert the array into an array list.