更新时间:2022-04-19 22:50:55
String stringToSplit = This is the string to split;
String[] split = stringToSplit.split("character to split at");
在这种情况下, split [0]
结果将为'This', split [1]
将为'is', split [2]
将为' ', split [3]
'字符串' split [4]
'到' split [5]
'split'。
In this case, split[0]
would result as ' This ', split[1]
would be ' is ', split[2]
would be ' the ', split[3]
' string ' split[4]
' to ' split[5]
' split '.
此时您可以执行
var0 = split[0];
var1 = split[1];
var2 = split[2];
其中 var0
等于 This
依此类推...
Where var0
would equal "This"
And so on...
希望这会有所帮助。