JAVA Write a method called isPalindrome that takes a string

**JAVA** Write a method called isPalindrome that takes a string as the parameter and returns true if the string is a palindrome, otherwise returns false. A palindrome is a string that reads the same backward and forward. You will need three stacks to implement this method.

The isPalindrome method should have the following signature and should be included in a class named PalindromeDetector.

public boolean isPalindrom(String input) { /* your implementation here */ }

Solution

public class Palindrome {

   public static void main(String[] args) {

       String s = \"abcdefgfedcba\";

       String s1 = \"fhjhg\";

       System.out.println(isPlaindrome1(s1));

   }

   public static boolean isPlaindrome(String s) {

       int l = s.length();

       for (int i = 0; i <= l / 2; i++)

           if (s.charAt(i) != s.charAt(l - i - 1))

               return false;

       return true;

   }

   public static boolean isPlaindrome1(String s) {

       Stack s1 = new Stack();

       for (int i = 0; i < s.length(); i++)

           s1.push(s.charAt(i));

       for (int i = 0; i < s.length(); i++) {

           if (s.charAt(i) != s1.pop()) {

               return false;

           }

       }

       return true;

   }

}

**JAVA** Write a method called isPalindrome that takes a string as the parameter and returns true if the string is a palindrome, otherwise returns false. A pali

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site