好像没有现成的api吧,自己动手写,不算烦的

解决方案 »

  1.   

    String str="Hello Tomtian,you r a lazy bone :)";
    int count=0;
    int index=0;
    while(index!=-1)
    {
        index=str.indexOf('o',index+1); //e.g how many 'o'
        if(index!=-1){count++;}
    }
    System.out.println("There are "+count+" o ");
      

  2.   

    Winuxava(用自己的工具,让别人去吵吧):
    你的程序没有问题吗?
    有点看不懂index=str.indexOf('o',index+1); 
    没有问题吗?
      

  3.   

    index=str.indexOf('o',index+1); 
    就算index+1超出范围了也是没问题的。