OOPS, Java Program | WAP to check whether a string is palindrome or not. - Helpwalaa - Free IT Updates & Opportunities

New Updates

OOPS, Java Program | WAP to check whether a string is palindrome or not.

 


OOPS, Java Program | WAP to check whether a string is a palindrome or not.

import java.util.*;
class palindrome{
public static void main(String x[]){
String str1,str2="";
Scanner t=new Scanner(System.in);
System.out.println("ENTER A STRING");
str1=t.nextLine();
int n=str1.length();
for(int i=n-1;i>=0;i--)
str2=str2+str1.charAt(i);
if(str1.equals(str2))
System.out.println(str1+" IS A PALINDROME");
else
System.out.println(str1+" IS NOT A PALINDROME");
}
}

Most Popular