Java Program to Check Palindrome Number in Java

 import java.util.Scanner;


public class PalindromeNumber {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);


        System.out.print("Enter an integer number: ");

        int original = sc.nextInt();


        int reversed = 0;

        int temp = original;


        while (temp != 0) {

            int digit = temp % 10;     // get last digit

            reversed = reversed * 10 + digit;  // build reversed number

            temp = temp / 10;          // remove last digit

        }


        if (original == reversed) {

            System.out.println(original + " is a Palindrome number");

        } else {

            System.out.println(original + " is not a Palindrome number");

        }


        sc.close();

    }

}


Comments

  1. Very informative and well-written article! The explanation provided here is clear and easy to understand for learners at all levels. Those who are looking to gain practical experience and job-ready skills can explore the No 1 Java Real Time Projects Online Training in Hyderabad, which offers hands-on learning with real-time projects. Thank you for sharing such useful and valuable information!

    ReplyDelete
  2. This is a very informative discussion about scalable system architecture. Developers who learn both Java programming and system design concepts can build more efficient and reliable applications. You can also explore Top System Design with Java Online Training in Hyderabad to understand real-world software architecture.

    ReplyDelete
  3. This is a very helpful article for beginners who want to build a strong foundation in Java. Understanding core concepts is essential before moving to advanced topics. Learners can explore Core JAVA Online Training to gain solid knowledge and improve their programming skills.

    ReplyDelete

Post a Comment

Popular posts from this blog

Write a socket program in java for simple stand alone chatting application.

Create a JSP page to accept a number from an user and display it in words: Example: 123 – One Two Three. The output should be in red color.

Write a JSP program to accept the details of Account (ANo, Type, Bal) and store it into database and display it in tabular form. (Use PreparedStatement interface)