Java 8 Stream API: Check if a String is a Palindrome

🚀 Stream API Coding – 1: Check if a String is Palindrome Exploring the power of Java 8 Stream API with a simple yet elegant example — checking whether a string is a palindrome using functional style. 💡 String s = "racecar"; boolean isPalindrome = IntStream.range(0, s.length() / 2) .allMatch(i -> s.charAt(i) == s.charAt(s.length() - i - 1)); System.out.println(isPalindrome ? "String is Palindrome" : "String is not palindrome"); ✨ Key Learnings: ✅ Use IntStream.range() for index-based iteration ✅ allMatch() ensures all comparisons pass ✅ Clean and concise approach — no loops, no extra variables 📚 Output: 👉 String is Palindrome This is just the beginning — more Stream API challenges coming soon! 🔥 #Java #StreamAPI #CodingChallenge #JavaDeveloper #FunctionalProgramming #CleanCode #CodingSeries #InterviewPreparation

This is a good coding question on Streams, Ramya Malemarpuram

See more comments

To view or add a comment, sign in

Explore content categories