Youtube Channel

Progaram to check given String is Palindrome or Not in Java

package com.pack.string;

import java.util.Scanner;

public class Stringpalindorme {

    public static void main(String[] args) {

        System.out.println("Enter the string");
        Scanner sc=new Scanner(System.in);
        String s=sc.nextLine();
        String n="";
        for(int i=s.length()-1;i>=0;i--)
        {
            n=n+s.charAt(i);
        }
        if(n.equals(s))
            System.out.println("palindrome");
        else
            System.out.println("not");
    }

}
Next PostNewer Post Previous PostOlder Post Home