Thursday, November 24, 2011

How to get list from array?


Use the Arrays asList method to get the list.

import java.util.Arrays;
import java.util.List;

public class GetListFromArray {
      public static void main(String[] args){
            String[] array = {"bat", "bet", "bit", "bot", "but"};
            List list = Arrays.asList(array);
            System.out.println(list);
      }
}

No comments:

Post a Comment