First Repeating character in a string
Please read the post for explanation:
Index of first repeated character in a string.
System.out.println("First repeating character in a string");
Set set=new HashSet<>();
"adffda".chars()
.filter(c->!set.add((char)c))
.findFirst()
.ifPresent(ch->System.out.print((char)ch));
Comments
Post a Comment