开发者

Converting ArrayList or Array to String Array

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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜