public String getString(List<Integer> list) {
        if (list == null || list.isEmpty()) {
            return null;
        }
        list.removeIf(e -> isNotValid(e));
        return list.stream().map(String::valueOf).collect(Collectors.joining(","));
    }

    private static Boolean isNotValid(Integer in) {
        if (in == null) {//为空的为无效数字
            return true;
        }
        return false;
    }
//输入:[1,2,3,null,5,null,7]
//输出:"1,2,3,5,7"

 

相关文章:

  • 2021-12-26
  • 2022-12-23
  • 2021-08-26
  • 2021-12-02
  • 2022-12-23
  • 2022-12-23
  • 2021-06-04
  • 2021-11-29
猜你喜欢
  • 2022-02-17
  • 2021-07-09
  • 2022-12-23
  • 2022-12-23
  • 2021-09-18
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案