Java Stream create from String

Description

Java Stream create from String

public class Main {
  public static void main(String[] args) {
    String str = "demo 2s.com 5 test,123,CSS,1,HTML, 2";
    str.chars()/*from w ww. java 2s  .c  om*/
    .filter(n ->  !Character.isDigit((char)n) &&   !Character.isWhitespace((char)n))
    .forEach(n ->  System.out.print((char)n));

  }
}



PreviousNext

Related