Word-
import java.util.Scanner;
class GFG {
public static void main (String[] args) {
//System.out.println("GfG!");
Scanner scan = new Scanner(System.in);
String word = scan.next();
StringBuffer sb = new StringBuffer(word);
String wordReverse = new String(sb.reverse());
if (word.equals(wordReverse))
System.out.println("yes");
else
System.out.println("no");
}
}
Number -
import java.util.Scanner;
class GFG {
public static void main (String[] args) {
//System.out.println("GfG!");
Scanner scan = new Scanner(System.in);
int number = scan.nextInt();
String numberString = Integer.toString(number);
StringBuffer sb = new StringBuffer(numberString);
String numberReverse = new String(sb.reverse());
if (numberString.equals(numberReverse))
System.out.println("yes");
else
System.out.println("no");
}
}
No comments:
Post a Comment