How to print each character from a string?

前端 未结 3 1709
离开以前
离开以前 2021-01-15 06:55

Is there a way to read a single character at a time from the input and process it, without tokenizing the vocabulary?

3条回答
  •  被撕碎了的回忆
    2021-01-15 07:16

    You can use Guava's CharMatcher to extract lower case letters from your string, then use Joiner to put each character on a new line.

    You can do all this in a single line of code as shown below:

    System.out.println(Joiner.on('\n').join(Lists.charactersOf(CharMatcher.JAVA_LOWER_CASE.retainFrom(s))));
    

提交回复
热议问题