查找字符串中第一個沒有重複出現的字符

1.     public class Simple{   spa

2.         public static char getChar(String text){   ci

3.             char c =0xff;   get

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

5.                 c =text.charAt(index);   ast

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

7.             }   im

8.             return c;   static

9.         }   top

10.         tab

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

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

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

14.      }   

15.  } 

相關文章
相關標籤/搜索