我有一個字符串,並希望有一個數量的字符之後將其分割...Java - 分割後的字符數?
示例代碼:
//This is what I have:
String text = "12345678";
List<String> tmpListFirst = new LinkedList<>();
List<String> tmpListSecond = new LinkedList<>();
int splitAfter = 3; //split after the second character (this value is variable)
//The result should look like this:
tmpListFirst.get(0) //== 678
tmpListFirst.get(0) //== 12345
看那['子串() String]類的'](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#substring(int))方法 – CubeJockey
你說3之後分裂,但你的輸出表明你想要它分裂後5 – UnknownOctopus