filmov
tv
Java How to Check if a String/Word Is a Palindrome (Simple)
Показать описание
Java How to Check if a String/Word Is a Palindrome
Greetings, in this Java tutorial we shall be checking if a string or word is a palindrome or not. A palindrome is a word, phrase, or sequence that reads the same backwards as forwards.
This video is a palindrome java program tutorial
We could use a Java stringbuilder, reverse a copy of the original string and check if they are equal, but instead we use a for loop. We are going to check the outermost character on each end of the string and compare them. If they match, we go in by 1 on each side and compare them.
If at any point, there isn't a match, we return a false. If we make it through the whole word/string, we return a true as it is a valid palindrome.
Thanks for watching this tutorial on how to check if a string or a word is a palindrome using Java.
Java How to Check if a String/Word Is a Palindrome
Greetings, in this Java tutorial we shall be checking if a string or word is a palindrome or not. A palindrome is a word, phrase, or sequence that reads the same backwards as forwards.
This video is a palindrome java program tutorial
We could use a Java stringbuilder, reverse a copy of the original string and check if they are equal, but instead we use a for loop. We are going to check the outermost character on each end of the string and compare them. If they match, we go in by 1 on each side and compare them.
If at any point, there isn't a match, we return a false. If we make it through the whole word/string, we return a true as it is a valid palindrome.
Thanks for watching this tutorial on how to check if a string or a word is a palindrome using Java.
Java How to Check if a String/Word Is a Palindrome