Saturday, February 26, 2011

Convert String array to ArrayList

import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
public class StringArrayTest
{
   public static void main(String[] args)
   {
      String[] fruits = {"apple", "banana", "coconut", "date", "eggplant"};
      List<String> fruitList = Arrays.asList(fruits);
      for (String str : fruitList)
      {
         System.out.println(str);
      }
   }
}

If you could click on some of the google ads you see on the right side. It will help me to run this blog and motivates me ;)

No comments:

Post a Comment