且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

java中字符串到字符串数组的转换

更新时间:2021-07-25 04:49:11

为了让你开始你的作业,String.split 在正则表达式上拆分字符串,这个表达式可能是一个空字符串:

To start you off on your assignment, String.split splits strings on a regular expression and this expression may be an empty string:

String[] ary = "abc".split("");

产生数组:

(java.lang.String[]) [, a, b, c]

摆脱空的第一个条目留给读者作为练习:-)

Getting rid of the empty 1st entry is left as an exercise for the reader :-)

注意:在 Java 8 中,不再包含空的第一个元素.

Note: In Java 8, the empty first element is no longer included.