java 两list求交集
程序员文章站
2022-03-07 15:20:45
...
String s1 = "50000,100000,200000,300000,500000,"; String s2 = "10000,30000,50000,100000,"; String[] a1 = s1.split(","); String[] a2 = s2.split(","); List<String> list = new ArrayList(Arrays.asList(a1)); list.retainAll(Arrays.asList(a2)); // list 中的就是交集了 for(String s : list){ System.out.println(s); }
上一篇: java基础
下一篇: 利用Rownum来限制查询