userimage

How to check a number is palindrome number or not using java code?

I need help to write code using java to check a number is palindrome or not. How to do ?

userimage

Try below code for checking a number is palindrome or not


import java.util.Objects;

/**
 * 
 * @author Deb
 *
 */
public class CheckPalindrum {

	public static void main(String[] args) {
		System.out.println(isPalindrome("128"));
		System.out.println(isPalindrome("121"));
	}

	private static boolean isPalindrome(String str) {
		if (Objects.isNull(str)) {
			return false;
		}
		StringBuilder strBuilder = new StringBuilder(str);
		strBuilder.reverse();
		return strBuilder.toString().equals(str);
	}
}
Answer is