Untitled

mail@pastecode.io avatar
unknown
plain_text
21 days ago
461 B
0
Indexable
Never
public class palindrome {
    public static boolean isPalindrome(int n) {
        int temp = n, rev = 0;
        temp = n;
        while(temp > 0) {   
            int rem = temp % 10;
            rev = rev*10 + rem;
            temp /= 10;
        }
        if (rev == n)
            return true;
        else
            return false;
    }
    public static void main(String[] args) {
        System.out.println(isPalindrome(129));
    }
}
Leave a Comment