大家好,又见面了,我是你们的朋友全栈君。
public class Test {
public static void main(String[] args) {
String[] animals = {“dog”,”cat”,”rabbit”,”fish”};
List animalList = Arrays.asList(animals);
for(String str : animalList){
System.out.println(str);
}
}
}
public class Test {
public static void main(String[] args) {
String[] animals = {“dog”,”cat”,”rabbit”,”fish”};
List animalList = new ArrayList(animals.length);
for(String str : animals){
animalList.add(str);
}
for(String str : animalList){
System.out.println(str);
}
}
}
public class Test {
public static void main(String[] args) {
String[] animals = {“dog”,”cat”,”rabbit”,”fish”};
List animalList = new ArrayList();
Collections.addAll(animalList, animals);
for(String str : animalList){
System.out.println(str);
}
}
}
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/172293.html原文链接:https://javaforall.cn