In this blog we are going to look into the palindrome program in Java. Main declaration: public class Main { public static void Main(String[] args) { variable initialisation: int r, sum = 0, temp; int n = 121; temp = n; invoking loops: while(n>0){ r = n%10; sum = (sum*10 + r); n = n/10; } testing condition: if(temp == sum){ System.out.println("palindrome"); } else System.out.println("non palindrome"); } } Full code: // public class Main { public static void main(String[] args) { int r, sum = 0, temp; int n = 121; temp = n; while(n>0){ r = n%10; sum = (sum*10 + r); n = n/10; } if(temp == sum){ System.out.println("palindrome"); } else System.out.println("non palindrome"); } }