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

Popular posts from this blog

Index of first repeated character in a string.

Usage of map,max,sorted,comparing java 8 methods