0

I'm working on a project where i need to convert either an ArrayList or and Array to an String array. I need each word/string to convert to seperate strings.

Something like this:

public ArrayList<String> arrList2 = new ArrayList<String>();

and then convert it and past into

public String arrList4 [] = new String [250];

Hope this is detaild enough so you get what i want.

1

2 Answers 2

2
ArrayList<String> al = new ArrayList<String>();

    al.add("C");
    al.add("java2s.com");
    al.add("D");
    al.add("F");
    al.add(1, "java2s.com");

    String[] strings = al.toArray(new String[al.size()]);
    System.out.println(Arrays.toString(strings));

Here is an interesting link: http://www.google.be/search?gcx=w&sourceid=chrome&ie=UTF-8&q=ArrayList+to+array

1

String []strArray = new String[250];
arrList2.toArray(strArray);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.