List<String> xList = new ArrayList<String>(); xList.add("1"); xList.add("2"); xList.add("3"); xList.add("4"); xList.add("5"); List<String> yList = xList.subList(1, 3); System.out.println(yList);
//加一个 yList.add("6"); System.out.println(yList); System.out.println(xList);
//再删掉 yList.remove(yList.size()-1); System.out.println(yList); System.out.println(xList);
结果: [2, 3] [2, 3, 6] //增加一个后 [1, 2, 3, 6, 4, 5] //原List也多了一个6 [2, 3] //删除一个后 [1, 2, 3, 4, 5] //原List也删掉了
|