我想像这样将值“o to p”子字符串化为两个字符串变量
o
p
我试图对这段代码进行子字符串化,但它似乎不起作用。
String x = rt.substring(rt.indexOf(" to ")+1);
返回“to p”
最佳答案
试试这个:
String[] output = "o to p".split(" to ");
String var1 = output[0]; // "o"
String var2 = output[1]; // "p"
关于java - 在java中对中间字符进行子串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43699735/