Java 8 使用积累

183 阅读1分钟
  • 获取流中的手机号,并拼接成一个字符串,以逗号分隔

String deviceIds =personList.stream() .map(Person::getPhoneNum).collect(Collectors.joining(","));

  • 将字符串以;分割生成流并转换为list

String period = "23;fds;adfs;" List<String> periodList = Arrays.stream(period.split(";")).collect(Collectors.toList());