Program to print all palindromes in a given range | Java Program to print all palindromes in a given range ; A function to check if n is palindrome ; Find reverse of n ; If n and rev are same , then n is palindrome ; prints palindrome between min and max ; Driver Code
class GFG { static int isPalindrome ( int n ) { int rev = 0 ; for ( int i = n ; i > 0 ; i /= 10 ) rev = rev * 10 + i % 10 ; return ( n == rev ) ? 1 : 0 ; } static void countPal ( int min , int max ) { for ( int i = min ; i <= max ; i ++ ) if ( isPalindrome ( i ) == 1 ) System . out . print ( i + " ▁ " ) ; } public static void main ( String args [ ] ) { countPal ( 100 , 2000 ) ; } }