去哪儿网笔试题——取出第一个重复的字符

 1 package com.shb.java;
 2 /**
 3  * 取出第一个重复的字符
 4  * @author shaobn
 5  * @date 2016-9-28
 6  * @package_name com.shb.java
 7  */
 8 public class Demo10 {
 9 
10     /**
11      * @param args
12      * @date 2016-9-28
13      * @author shaobn
14      */
15     public static void main(String[] args) {
16         // TODO Auto-generated method stub
17             findFirstRepeat("wqyqwyer23tdd",11);
18     }
19     /**
20      * 实现方法
21      * @param str
22      * @param n
23      * @date 2016-9-28
24      * @author shaobn
25      */
26     public static void findFirstRepeat(String str,int n){
27         char[] ch = str.toCharArray();
28     out:    for(int i=0;i<n-1;i++){
29             for(int j = i+1;j<n;j++){
30                 if(ch[i]!=ch[j]){
31                     continue;
32                 }else {
33                     System.out.println(ch[i]);
34                     break out;                    
35                 }
36             }
37             
38         }
39         
40         
41     }
42 }
原文地址:https://www.cnblogs.com/assassin666/p/5918216.html