How to convert a String into an array of Strings containing one character each

前端 未结 6 925
攒了一身酷
攒了一身酷 2020-12-15 12:13

I have a small problem here.I need to convert a string read from console into each character of string. For example string: \"aabbab\" I want to this string into array of st

6条回答
  •  难免孤独
    2020-12-15 13:09

    String[] result = input.split("(?!^)");
    

    What this does is split the input String on all empty Strings that are not preceded by the beginning of the String.

提交回复
热议问题