Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java: convert an object array to a collection

Java: convert an object array to a collection
{filelink=12225}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Generic_Meth
{
  // The method takes an array of objects and returns a list
  public static List convert_Tab(T[] tableau)
  {
  	List list=new ArrayList();
  	list=Arrays.asList(tableau);
  	return list;
  }
  public static void main (String[] args)
  	{
  	   String [] tab_Str={"A", "B", "C"};
       List   mysList=convert_Tab(tab_Str);
       System.out.println (mysList);
       Integer [] tab_Int={1, 8, 16};
       mysList=convert_Tab(tab_Int);
       System.out.println (Arrays.asList(mysList));
    }
}

Users who found this page were searching for:

  • how to time an operation in java
  • tkinter pause animation
  • perl random value from array
  • python if while key press
  • use of comma operator in for loop

No comments yet.

Leave a Comment