我正在尝试设计一个循环,该循环将通过一个 Spring ,一旦它到达 % 字符,它就会将 % 之后的所有内容传递给 hexToInt 函数。这是我想出的。
for(int x=0; x<temp.length(); x++)
{
if(temp.charAt(x)=='%')
{
newtemp = everthing after '%'
hexToInt(newtemp);
}
}
最佳答案
试试这个:
newtemp = temp.substring(x+1);
此外,您应该在找到 '%'
字符后中断。事实上,整个代码片段可以像这样实现(不需要为它编写循环!):
String newtemp = temp.substring(temp.indexOf('%')+1);
关于java - 将字符串的一部分作为参数传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18433030/