/* JAVA PROGRAM TO CHECK GIVEN STRING IS
PALINDROME OR NOT */
class PalindromeDemo{
public static void main(String[] args){
String s1=new String("madam");
String reverse="";
for(int i=s1.length()-1;i>=0;i--){
reverse=reverse+s1.charAt(i);
}
if(s1.equals(reverse)){
System.out.println("the given string is palindrome");
}
else{
System.out.println("the given string is not palindrome");
}
}
}
PALINDROME OR NOT */
class PalindromeDemo{
public static void main(String[] args){
String s1=new String("madam");
String reverse="";
for(int i=s1.length()-1;i>=0;i--){
reverse=reverse+s1.charAt(i);
}
if(s1.equals(reverse)){
System.out.println("the given string is palindrome");
}
else{
System.out.println("the given string is not palindrome");
}
}
}
No comments:
Post a Comment