public
class
StringArrayTest
{
public
static
void
main(String[] args)
{
String[] words = {
"ace"
,
"boom"
,
"crew"
,
"dog"
,
"eon"
};
List<String> wordList = Arrays.asList(words);
for
(String e : wordList)
{
System.out.println(e);
}
}
}
但是Arrays.asList方法返回的List大小是固定的,不能执行add,remove等操作。
可以用List list = new ArrayList(Arrays.asList(array));
时间: 2024-10-11 14:44:36