JAVA8新特性之两集合求差集

红太狼 2021-09-07 06:02 528阅读 0赞
  1. //字符串转数组
  2. String[] split = ticketType1.split(",");
  3. //两集合求差集
  4. List<String> reduce2 = Arrays.asList(split).stream().filter(item -> !Arrays.asList(ticketType.split(",")).contains(item)).collect(Collectors.toList());
  5. //集合转数组
  6. String[] strings = new String[reduce2.size()];
  7. String[] strings1 = reduce2.toArray(strings);
  8. //数组转字符串
  9. String s = ArrayUtils.toString(strings1);
  10. baseTicket.setTicketType(s);

发表评论

表情:
评论列表 (有 0 条评论,528人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Java8 个List

    常规做法就是使用两个循环,遍历两个list,然后使用迭代器删除id相等的数据,这种方法比较简单,但是代码层级比较深,不值得推荐;,当这一项的userId不存在于exitL...