package com.usr;
import java.util.Scanner;
public class PalindromeString {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Enter the string :");
String original=sc.next();
int length=original.length();
String reverse="";
for(int i=length-1;i>=0;i--){
reverse=reverse+original.charAt(i);
}
if(original.equals(reverse)){
System.out.println("string is palindrome");
}
else{
System.out.println("string is not a palindrome and the reverse of string is:"+reverse);
}
}
}
import java.util.Scanner;
public class PalindromeString {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Enter the string :");
String original=sc.next();
int length=original.length();
String reverse="";
for(int i=length-1;i>=0;i--){
reverse=reverse+original.charAt(i);
}
if(original.equals(reverse)){
System.out.println("string is palindrome");
}
else{
System.out.println("string is not a palindrome and the reverse of string is:"+reverse);
}
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.