本文介绍了两个List< String>的有效交集在Java?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问题很简单:
我有两个清单
List<String> columnsOld = DBUtils.GetColumns(db, TableName); List<String> columnsNew = DBUtils.GetColumns(db, TableName);我需要得到这些的交集。有没有快速实现此目的?
And I need to get the intersection of these. Is there a quick way to achieve this?
推荐答案您可以使用 retainAll 方法:
You can use retainAll method:
columnsOld.retainAll (columnsNew);更多推荐
两个List< String>的有效交集在Java?
发布评论