Java Array class asList(T... a) example
Array class asList(T... a) method example
Array class asList(T... a) method example. This example shows you how to use asList(T... a) method.This method Returns a fixed-size list backed by the specified array.
Here is the code:-
/**
* @Program that Returns a fixed-size list backed by the specified array.
* asListArray.java
* Author:-RoseIndia Team
* Date:-15-May-2008
*/
import java.util.*;
public class asListArray {
public static void main(String[] args) {
//Declaring an object array
Object arr[]={"Rose","India","Limited","Rohini"};
//viewing the array as list
List l=Arrays.asList(arr);
//Displaying the list
System.out.println(l);
}
} |
Output of the program:-
| [Rose, India, Limited, Rohini] |
|