From the course: Nail Your Java Interview
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Solution: Developing a Palindrome Checker - Java Tutorial
From the course: Nail Your Java Interview
Solution: Developing a Palindrome Checker
(upbeat music) - [Instructor] Let's implement a function that determines if a string is a palindrome. Remember, a palindrome is a word or phrase which reads the same backwards as it does forwards. We'll start by normalizing the input and converting it to lowercase. This will ensure that we treat uppercase and lowercase letters as the same. For our implementation, we'll create a reverse string and check if the reverse string is the same as our input string. We'll use a string builder to create that reverse string. Then we'll iterate through the normalized string backwards, appending each character to our reverse string builder. At the end, we'll convert our reverse string builder to be a string, and then compare it with the normalized string. If the strings are equal, then the original string must be a palindrome. Let's run it. Our implementation works as expected. Now, how can we improve this? Well, instead of manually reversing the string, there are string builder functions and…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Concatenate strings with different methods3m 20s
-
(Locked)
Normalize string input4m 13s
-
(Locked)
Access data from strings4m 44s
-
(Locked)
Apply string functions in technical interviews4m 35s
-
(Locked)
Understand string equality4m 2s
-
(Locked)
Solution: Developing a Palindrome Checker3m 49s
-
(Locked)
Solution: Counting with String Manipulation2m 40s
-
-
-
-
-