import java.util.ArrayList;
import java.util.List;
public class CloneListExample {
public static void main(String[] args) {
List originalList = new ArrayList<>();
originalList.add("Apple");
originalList.add("Banana");
originalList.add("Orange");
List clonedList = new ArrayList<>(originalList.size());
for (String item : originalList) {
clonedList.add(item);
}
clonedList.add("Grapes");
System.out.println("Original List: " + originalList);
System.out.println("Cloned List: " + clonedList);
}
}
顶一下
(0)
0%
踩一下
(0)
0%
- 相关评论
- 我要评论
-
上一篇:返回栏目
下一篇:c python和java