OOPS Java Programs | WAP to create a function reverse() which returns the reverse of an integer.
Use this function in main() to check whether a given number is
palindrome or not.
import java.util.*;
class palindrome{
int reverse(int n){
int d,rev=0;
while(n!=0){
d=n%10;
rev=rev*10+d;
n=n/10;
}
return rev;
}
}
class test{
public static void main(String x[]){
Scanner t=new Scanner(System.in);
System.out.println("ENTER A NUMBER");
int n=t.nextInt();
int a=n;
palindrome p=new palindrome();
int c=p.reverse(n);
if(c==a)
System.out.println("NUMBER IS PALINDROME");
else
System.out.println("NUMBER IS NOT A PALINDROME");
}
}