String pop = "|1|3|4|5|1|5|3|2|";//....String[] result = pop.split("|");
for(x = 0 ; x< 100 ; x++)if (result[x].equals("0"))
{//println...}
...
if (result[x].equals("1")
...
if (result[x].equals("2")//这里我想用循环来做,实现0到50的判断,请教各位我该怎么做?//问题在与,result[]是String[]类型,int i是整数类型//如果简单用个i,就报错说类型不一样,如果放进去一个数字,又不能正确的判断.//求大家帮忙!弄晕了.}

解决方案 »

  1.   

    String pop = "|1|3|4|5|1|5|3|2|";
    String[] result = pop.split("|"); 
    int ttt = result.getLength();int[] aaa = new int[ttt];
    for(int i = 0; i < ttt; i++)
        aaa[这里字符串转为数字(result[i])] ++;for(int i = 0; i < ttt; i++)
    {
        if(aaa[i] > 0)
           System.out.ptintln(i);
    }
      

  2.   

    String pop = "|1|3|4|5|1|5|3|2|";//.... 
    String[] result = pop.split("|"); int one = result.length();
    for(int x = 0 ; x < one-1 ; x++) {
       for(int i = 0; i < one-1; i++)
       {
          if (result[x].equals(""+i) 
          {
              System.out.println(result[x]);
          }
     
       }
    }
      

  3.   

    双for 循环可以解决你的问题。使用强制类型转换,""+1 他的结果是 String 类型
      

  4.   

           public static void main(String[] args) {
    String pop = "|1|3|4|5|1|5|3|2|";
    String[] result = pop.split("|"); 
    int a = result.length;
    for(int x = 0 ; x < a ; x++){
    if(!result[x].equals("|")){
    String str = Integer.toString(x/2);
    if(result[x].equals(str))System.out.println(str);
    }
    }
    }
    结果是:1
      

  5.   

    你的问题是类型转换?
    整数类型转string型用String.valueof(int a);
      

  6.   


    public static void main(String[] args) {        String pop = "|1|3|4|5|1|5|3|2|";
            String[] result = pop.split("|");
            int i;        for (String str : result) {
                try {
                    i = Integer.parseInt(str);
                } catch (Exception e) {
                    continue;
                }
                if (i >= 0 && i <= 50) {
                    System.out.println(i);
                }
            }
        }
      

  7.   

    把int转成String或者把String转成int。
      

  8.   


    当pop="|1|3|4|5|1|5|3|2|50|51",打印结果是这样:
    1
    3
    4
    5
    1
    5
    3
    2
    5
    0
    5
    1不知是什么原因,请大家一起来分析~~~
      

  9.   

    pop.split("|");   ----->   pop.split("\\|");