India’s Best Job Seekers and Training Platform Forums Java Problems set Given a string "L*&EVe)))l", write a method…

  • Given a string "L*&EVe)))l", write a method…

     Akash  updated 11 months, 2 weeks ago 2 Members · 2 Posts
  • Akash 

    Administrator
    at

    Given a string “L*&EVe)))l”, write a method which will determine if the input is a palindrome. Ignore all special characters. Uppercase/lowercase should be considered as same.

  • Akash 

    Administrator
    at

    public class Manish

    {

    static Boolean sentencePalindrome(String str)

    {

    int i = 0;

    int h = str.length()-1;

    str = str.toLowerCase();

    while(i <= h)

    {

    char getAti = str.charAt(i);

    char getAth = str.charAt(h);

    if (!(getAti >= ‘a’ && getAti <= ‘z’))

    i++;

    else if(!(getAth >= ‘a’ && getAth <= ‘z’))

    h–;

    else if( getAti == getAth)

    {

    i++;

    h–;

    }

    else

    return false;

    }

    return true;

    }

    public static void main(String[] args)

    {

    String str = “L*&EVe)))l”;

    if( sentencePalindrome(str))

    System.out.println(“Sentence is palindrome”);

    else

    System.out.println(“Sentence is not” + ” ” +

    “palindrome”);

    }

Log in to reply.

Original Post
0 of 0 posts June 2018
Now
KodNest Training New Batch is starting on 02nd November 2020. Attend one week free demo classes.Register Now

New Report

Close