I have written below code for detecting first duplicate character in a string.
public static int detectDuplicate(String source) { boolean found = false;
You could try with:
public static char firstRecurringChar(String s) { char x=' '; System.out.println("STRING : "+s); for(int i =0;ii){ x=s.charAt(i); break; } } return x; }