找到第一个不重复的字母

2012-11-12

    package lianxi;
    public class OnlyOneWord {
    public static void main(String arg[]){
    replaceChar("wsevujdhkvdjks");
    }
    public static void replaceChar(String test){
    boolean isFind=false;
    while(test.length()>0){
    char tempChar=test.charAt(0);
    if(test.indexOf(tempChar)==test.lastIndexOf(tempChar)){
    System.out.println("重复的数字:"+tempChar);
    isFind=true;
    break;
    }
    else{
    test=test.replaceAll(String.valueOf(tempChar),"");
    }
    }
    if(!isFind){
    System.out.println("无重复的字母");
    }
    }
    }

  考试大温馨提示:本内容来源于网络,仅代表作者个人观点,与本站立场无关,仅供您学习交流使用。其中可能有部分文章经过多次转载而造成文章内容缺失、错误或文章作者不详等问题,请您谅解。如有侵犯您的权利,请联系我们,本站会立即予以处理。

分享到:
0
相关阅读
友情链接
© 2018 我考网 http://www.woexam.com 中国互联网举报中心 湘ICP备18023104号 京公网安备 11010802020116号
违法和不良信息举报:9447029@qq.com