Write a Java program to check if a positive number is a palindrome or not

Source Code:

public class P24 {
public static void main(String[] args) {
int n = 121, rev = 0, temp = n;
while(temp > 0) {
rev = rev * 10 + temp % 10;
temp /= 10;
}
System.out.println(n == rev);
}
}

Output: