我想将像“My dog”这样的字符串拆分成一个数组:
| M | y | space char will be in here | D | o | g |
这是我的代码:
String []in_array;
input = sc.next();
in_array = input.split(""); //Note this there is no delimiter
for(int k=1; k < in_array.length; k++){
System.out.print(" "+in_array[k]);
}
编辑:
它只打印出“我的”
最佳答案
java.lang.String 有一个 toCharArray()正是这样做的。
关于java - 拆分没有分隔符的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13453075/