To start you off on your assignment, String.split
splits strings on a regular expression, this expression may be an empty string:
(为了让你的作业开始, String.split
在正则表达式上拆分字符串,这个表达式可能是一个空字符串:)
String[] ary = "abc".split("");
Yields the array:
(产生数组:)
(java.lang.String[]) [, a, b, c]
Getting rid of the empty 1st entry is left as an exercise for the reader :-)
(摆脱空的第一个条目留给读者练习:-))
Note: In Java 8, the empty first element is no longer included.
(注意:在Java 8中,不再包含空的第一个元素。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…