Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

This question already has an answer here:

How do I convert String Array to Array List:

String[] to ArrayList<String>

share|improve this question

marked as duplicate by Amulya Khare, Sri Harsha Chilakapati, Devolus, Ondrej Janacek, Mureinik Dec 6 '13 at 7:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  

5 Answers 5

up vote 0 down vote accepted

Try this one

private ArrayList<String> list = new ArrayList<String>();
list.clear();

for(int i=0;i<StringArray.length;i++)
{
    list.add(StringArray[i]);
}
share|improve this answer
    
its working fine .. –  user3073306 Dec 6 '13 at 6:52

Try this:

String[] words = {"ace", "boom", "crew", "dog", "eon"};  

List<String> wordList = Arrays.asList(words);  

for (String e : wordList)  
{  
    System.out.println(e);  
}  
share|improve this answer

You can do

  • Use the Arrays.asList() method

    List<String> list = Arrays.asList(strings);
    
  • Create a new ArrayList and copy the elements of the array (not recommended)

    List<String> list = new ArrayList<String>();
    
    for (String str : strings)
    {
        list.add(str);
    }
    

Hope this helps.

share|improve this answer

Try this..

String[] arr = { "40", "50", "60", "70", "80", "90", "100", };

ArrayList<String> arr_list = new ArrayList<String>();

for (int i = 0; i < arr.length; i++)
    arr_list.add(arr[i]);

or

ArrayList<String> arr_list = new ArrayList<String>(Arrays.asList(arr)); 
share|improve this answer

Try this:

String [] strings = new String [] {"stack", "overflow" };
List<String> stringList = new ArrayList<String>(Arrays.asList(strings)); 
share|improve this answer