Search

Palindrome Program in Java || Java Programs

Palindrome number in java: A palindrome number is a number that is same after reverse. For example 545, 151, 34543, 343, 171, 48984 are the palindrome numbers. It can also be a string like LOL, MADAM etc.


Program -


class PalindromeExample{  
 public static void main(String args[]){  
 int r,sum=0,temp;    
 int n=454;//It is the number variable to be checked for palindrome 
 
  temp=n;    
 while(n>0){    
   r=n%10;  //getting remainder 
   sum=(sum*10)+r;    
   n=n/10;    
  }    
 if(temp==sum)    
   System.out.println("palindrome number ");    
 else 
   System.out.println("not palindrome");    
}  
}  

Output -

palindrome  number


1 view0 comments

Related Posts

See All

How to Print Pattern in Java || Java Programs

Java pattern program enhances the coding skill, logic, and looping concepts. It is mostly asked in Java interview to check the logic and thinking of the programmer. We can print a Java pattern program

How to Generate Random Number in Java || Java Programs

In real world projects, we often required to generate random numbers while we develop applications. Many applications have the feature to generate numbers randomly, such as to verify the user many app

Armstrong Number in Java || Java Programs

Armstrong Number in Java: A positive number is called armstrong number if it is equal to the sum of cubes of its digits for example 0, 1, 153, 370, 371, 407 etc. Let's try to understand why 153 is an

  • Facebook
  • Instagram
  • LinkedIn
  • 1024px-Telegram_logo.svg
  • download
  • YouTube
  • Google Play