classSolution{publicbooleanisPalindrome(intx){if(x<0)returnfalse;intreversedInteger=0,lastDigit,temp;temp=x;// storing the original number to a temporary variable// Reversing the numberwhile(temp!=0){lastDigit=temp%10;reversedInteger=reversedInteger*10+lastDigit;temp=temp/10;}// checking if palindrome or not using conditionif(reversedInteger==x)returntrue;elsereturnfalse;}}