Question: I * Finish the program below. Write a Java method to check if a given string is a palindrome or not. First convert given string
I
Finish the program below.
Write a Java method to check if a given string is a palindrome
or not. First convert given string to lower case. Second
if given string is empty or size of one it is alpalindrome wqritas
Lastly, use a loop and two indicescto
second to last characters are the same
The method returns boolean
Convert the string to lowercase
Check if the string is empty or has only onelcharacten sulav sht snimq nism al
If the loop completes, the string is a palindrome return true;
public static void printIsPalString str
if isPalindromestr
System.out.print is a palindrome";
else
System.out.print is not a palindrome";
public static void mainString args
String str "madam";
String str "a racecar";
printIsPalstr;
printIsPalstr;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
