Java 抓取字符串中的下一个数字

Java 抓取字符串中的下一个数字,java,string,arraylist,Java,String,Arraylist,嗨,我有一个字符串的数组列表,它包含一堆数字,我得到了每个“阶段”中的数字。但在第二阶段,它只抓取1而不是10,我还能抓取字符串中的下一个整数吗?我让它适用于任何小于10的数字,但在10之后它就消失了 int stage = 1; // depending on where it is placed in the program it changes String voteOne = "1 10 3 4 5 6 7 8 9 2"; char vote = voteOne.ge

嗨,我有一个字符串的数组列表,它包含一堆数字,我得到了每个“阶段”中的数字。但在第二阶段,它只抓取1而不是10,我还能抓取字符串中的下一个整数吗?我让它适用于任何小于10的数字,但在10之后它就消失了

   int stage = 1; // depending on where it is placed in the program it changes
   String voteOne = "1 10 3 4 5 6 7 8 9 2"; 
   char vote = voteOne.getCharAt(stage); 
将返回一个字符串数组。然后是Integer.parseInt(),每个字符串。阅读以下两种方法的文档:


使用和然后来解决此问题。

只需
Integer.parseInt(voteOne.split(“”[stage])
就可以为每个stage重新点燃整个字符串,最好将split()的结果作为某个地方的引用
voteOne.split("\\s")