查找字符串中第一个没有重复出现的字符

1.     public class Simple{   

2.         public static char getChar(String text){   

3.             char c =0xff;   

4.             for(int index =0;index <text.length();index ++){   

5.                 c =text.charAt(index);   

6.                 if(text.indexOf(c) ==text.lastIndexOf(c)) break;   

7.             }   

8.             return c;   

9.         }   

10.         

11.      public static void main(String[] args){   

12.          System.out.println(getChar("teeter"));   

13.          System.out.println(getChar("teeterh"));   

14.      }   

15.  } 

posted @ 2015-10-18 15:08  AerialLadder  阅读(293)  评论(0编辑  收藏  举报