![]() By using remainder and division operator in Java we can create program to check if number is palindrome or not. Thankfully Java provides couple of arithmetic operators like remainder(%) operator also known as modules operator, which returns remainder in division operator and division operator(/) which returns quotient. For example 121 is a palindrome because reverse of 121 is 121, while 123 is not a palindrome in Java because reverse of 123 is 321 and 121!=321.įinding palindrome number is easy in Java, you just need to develop. For those who are not familiar with palindrome numbers, palindrome number is a number which is equal to reverse of itself. In this java program, we will get a number variable and check whether number is palindrome or not. Palindrome number algorithm Get the number to check for palindrome Hold the number in temporary variable Reverse the number Compare the temporary number with reversed number If both numbers are same, print 'palindrome number' Else print 'not palindrome number' Let's see the palindrome program in java. Write a Java program to check if number is palindrome comes from same category. It can also be a string like LOL, MADAM etc. When you start learning Java programming most institute which teach Java programming provides these classical Java programs like or etc. Hence, if all the conditions are satisfied, the string is a palindrome.Ĭhecking whether a number is palindrome or not is a classical Java homework exercise.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |