Question: I am trying to create this java program --my code-- import java.util.Scanner; public class Main { public static void main(String[] args) { // Create a
I am trying to create this java program

--my code--
import java.util.Scanner;
public class Main { public static void main(String[] args) { // Create a Scanner Scanner input = new Scanner(System.in);
// Prompt the user to enter a string System.out.print("Enter a string: "); String s = input.nextLine();
// The index of the first character in the string int low = 0;
// The index of the last character in the string int high = s.length() - 1;
boolean isPalindrome = true; while (low
low++; high--; }
if (isPalindrome){ System.out.println(s + " is a palindrome");} else if (!isPalindrome){ System.out.println(s + " is not a palindrome"); } else if (s == "0"){ System.out.println( " Thank you. "); } else { System.out.println( " wrong input "); }
} }
when I input a palindrome, it says not a palindrome. However, input 0 says it is a palindrome.
![public class Main { public static void main(String[] args) { // Create](https://s3.amazonaws.com/si.experts.images/answers/2024/09/66d9b12ce20c3_70066d9b12c89871.jpg)

Is there any way to fix this?
Enter a string: 0 0 is a palindrome java -cp /tmp/DEFePV860B Main Enter a string: my gym my gym is not a palindrome
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
