我如何将列表放入数组 [英] How can i put a list to array

查看:126
本文介绍了我如何将列表放入数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何放置字符串列表,键入字符串

How can i put a list of strings, type string

  String countryList[] = {a};

a是具有列表的变量

所以,它将是

  String countryList[] = {"heyyesGabon","heyyesGibraltar","heyyesGuinea"}; //and the others

此列表来自javascript中的console.log

this list comes from console.log in javascript

它总是保存最后一个项目

it always save the last item

推荐答案

您可以使用内置函数list.toArray(stringArray);,它将返回String[].

You can use in-build function list.toArray(stringArray); it will return String[].

String countryList[] = new String[list.size()];
countryList = list.toArray(countryList);

希望这会对您有所帮助.

Hope this will help you.

这篇关于我如何将列表放入数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆