Java Arrays.asList(T... a)
Syntax
Arrays.asList(T... a) has the following syntax.
@SafeVarargs public static <T> List <T> asList(T... a)
Example
In the following code shows how to use Arrays.asList(T... a) method.
/*from w w w .ja v a2 s. c o m*/
import java.util.Arrays;
import java.util.List;
public class Main {
public static void main (String args[]) {
// create an array of strings
String a[] = new String[]{"CSS","HTML","Python","tutorial from java2s.com"};
List<String> list1 = Arrays.asList(a);
// printing the list
System.out.println("The list is:" + list1);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »