Number Palindrome in Java

Here you will find out about number palindrome in java.

A number is called palindrome in the event that it is equivalent to its invert.

For instance, 1221 is a palindrome while 1234 isn’t a palindrome.

Underneath I have shared the java program to check the given number is a palindrome or not.

Program for Number Palindrome in Java

Program

class Palindrome
{
	public static void main(String...s)
	{
		int n,m,rev=0,i;
		n=Integer.parseInt(s[0]);
		m=n;
		
		while(n!=0)
		{
			i=n%10;
			rev=(rev*10)+i;
			n/=10;
		}
		
		if(m==rev)
			System.out.println("\nNumber is palindrome");
		else
			System.out.println("\nNumber is not palindrome");
	}
}

Output

Number Palindrome in Java

Leave a Comment

error: Alert: Content is protected!!