Excel表格网

java cloneLIST

141 2024-03-09 14:47 admin   手机版
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