Hi to all!!!! I Am Arpit Vijay Vergiya.
On this Blog i tried to share about Java.
I hope this blog will help you to learn many new things in java.
Keep visiting!!!
Keep sharing

by

How to check given String is palindrom or not in java

String is palindrom or not


import java.util.Scanner;
class StringPalindrom{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    System.out.println("Enter a line");
    String str = sc.nextLine();
    String str1="";
    char ch[] = str.toCharArray();
    for(int i=ch.length-1;i>=0;i--)
    {
      str1+=ch[i];
    }
     if(str.equals(str1))
      System.out.println("Palindrom");
     else
      System.out.println("Not palindrom");
    
    
  }
}






0 comments:

Post a Comment