import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
public class FirstNonRepeated {
public static void main(String[] args) {
String input = "swiss";
/*Character result = findFirstNonRepeated(input);
System.out.println("First non-repeated character: " + result);*/
Character result = input.chars()
.mapToObj(c -> (char)c)
.filter(ch -> input.indexOf(ch) == input.lastIndexOf(ch))
.findFirst()
.orElse(null);
System.out.println("result ****** :"+result);
}
}
Kubernate
Java 8 # FindFirstNonRepeated Character
Subscribe to:
Comments (Atom)
Spring Boot - Bean LifeCycle
Here is a clear, step-by-step lifecycle of a Spring Boot application , explained in a simple + interview-ready way. 🔄 Spring Boot Applica...
Kubernate
-
Features in Java 8 Key Features in Java 8 Lambda Expressions Functional Interfaces Streams API Optional Cl...
-
Java throw and throws Keywords Introduction The throw and throws keywords in Java are used to handle exceptions. They play a c...
-
Java Enums Introduction Enums in Java provide a way to define a set of named constants. They are used to represent a fixed set of valu...
No comments:
Post a Comment