Java Program to check whether number is Palindrome or not | Java Find Palindrome Number

Blogs ❯❯ Java

What is palindromic number ?

palindromic number वो numbers होते हैं जिनके digits reverse करने पर meaning / value same ही रहती है। example के लिए 2002 इसे reverse करने पर भी इसकी value same ही रहेगी। इसी तरह से 1221 और बाकी कुछ numbers भी होते हैं।

Image could not load

Image on pixabay

इस article में Java में हम Palindrome number check करने के लिए method की help से program बनाएंगे , जिसमे एक number pass करने पर हमें boolean value मिलेगी। अगर pass किया गया number , Palindrome है तो true otherwise false return होगा।

Java program to check palindrome number

// import package. import java.util.*; class Palindrome { // Function to check for Palindrome number. public static boolean isPalindrome(int number) { int temp = number; int newNumber = 0; while (temp > 0) { int digit = temp % 10; newNumber = newNumber * 10 + digit; temp = temp / 10; } if (newNumber == number) return true; else return false; } public static void main(String[] args) { // get number from user number. Scanner sc = new Scanner(; System.out.println("Enter a number: "); int number = sc.nextInt(); // now call function. boolean result = isPalindrome(number); if (result) System.out.println("Number is Palindrome"); else System.out.println("Number is not Palindrome"); } }

Output :

Enter a number: 1234
Number is not Palindrome

Enter a number: 101
Number is Palindrome
Recent Blogs

Loading ...

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook