Number is Palindrome or Not in Java

Java program to check for a Palindrome number.Get an input number or string. Get the reverse of the input number or string Compare the two numbers and string same or Not same.

The if statement is Java's conditional branch statement. It can be used to route program execution through two different paths. The if statement is the most basic of all the control flow statements. It tells your program to execute a certain section of code only if a particular test evaluates to true. The if statement is written with the if keyword, followed by a condition in parentheses, with the code to be executed in between curly brackets.

The below program checks for a Palindrome number using a loop. A for loop is a repetition control structure which allows us to write a loop that is executed a specific number of times. The loop enables us to perform n number of steps together in one line. In for loop, a loop variable is used to control the loop.

Source Code

import java.util.Scanner;
public class number_palindrome {
    public static void main(String args[])
        Scanner in = new Scanner(;
        System.out.print("Enter The Number : ");
        int n = in.nextInt();
        int temp=n;
        int reverse=0, rem;
            System.out.println(reverse+" Number is Palindrome");
        }else {
            System.out.println(reverse+" Number is Not a Palindrome");


Enter The Number : 64546
64546 Number is Palindrome
Enter The Number : 4654
4564 Number is Not a Palindrome
To download raw file Click Here

Basic Programs