Java - What is the best way to find first duplicate character in a string

前端 未结 7 1416
我寻月下人不归
我寻月下人不归 2020-12-19 09:02

I have written below code for detecting first duplicate character in a string.

public static int detectDuplicate(String source) {
    boolean found = false;         


        
7条回答
  •  渐次进展
    2020-12-19 09:42

    You could try with:

     public static char firstRecurringChar(String s)
        {
        char x=' ';
        System.out.println("STRING : "+s);
        for(int i =0;i
                                                            
提交回复
热议问题