Share your knowledge with other learners . . . Login Register

Blogs ❯❯ Java

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

Top Blogs

Loading ...

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
Give Feedback

like-image 0.

Recent Blogs

Loading ...

Rahul Kumar

Rahul Kumar

Hi ! My name is Rahul Kumar Rajput. I'm a back end web developer and founder of I live in Uttar Pradesh (UP), India and I love to talk about programming as well as writing technical tutorials and tips that can help to others.

Get connected with me. :) LinkedIn Twitter Instagram Facebook