Java Check Whether String Is Palindrome | Java 8 Stream NoneMatch Example | InterviewDOT
Channel: Interview DOT
Date: 22/06/2020

Click here - https://www.youtube.com/channel/UCd0U_xlQxdZynq09knDszXA?sub_confirmation=1 to get notifications.

Java Check Whether String Is Palindrome | Java 8 Stream NoneMatch Example | InterviewDOT

Code : https://github.com/net-vinothkumar/ILoveJavaProgramming

The stream noneMatch() method works just opposite to the anyMatch() method, it returns true if none of the stream elements match the given predicate, it returns false if any of the stream elements matches the condition specified by the predicate.

Java 8 Stream allMatch, anyMatch and noneMatch methods are applied on stream object that matches the given Predicate and then returns boolean value. allMatch() checks if calling stream totally matches to given Predicate, if yes it returns true otherwise false. anyMatch() checks if there is any element in the stream which matches the given Predicate. noneMatch() returns true only when no element matches the given Predicate.

Stream.noneMatch
noneMatch() method is a method which takes argument as a Predicate and if none of element of stream matches the given Predicate, then it returns true otherwise false.

To check if a string is a palindrome or not, a string needs to be compared with the reverse of itself.

Consider a palindrome string: radar