Responsive Ad Area

Share This Post

test

find a substring which is palindrome in given string

input is :levelmm
output is: the given string is palindrome because the given string contains level is a palindrome remain character like mm is neglected.

package example;

import java.util.Scanner;

public class exp2 {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    System.out.println("enter the string");
    Scanner scan=new Scanner(System.in);
    String s=scan.nextLine();
    String t="";
    String s1=s.substring(0, s.length()-1);

    for(int i=s1.length()-1;i>=0;i--)
{
    t=t+s.charAt(i);
}

    if(t.equalsIgnoreCase(s1))
    {
        int count=t.length();
        System.out.println("is palindrome"+(count-1));
    }else
    {
        System.out.println("not a palindrome");
    }
}

}
but its working completely..


find a substring which is palindrome in given string
find a substring which is palindrome in given string
test
{$excerpt:n}

Share This Post

Leave a Reply

Your email address will not be Publishedd. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Skip to toolbar