
java program to check whether a number is pallindrome or not using recursion???????

Java check number is palindrome or not:
import java.util.Scanner;
public class NumberPalindrome
{
public static boolean check(String s)
{
if(s.length() == 0 || s.length() == 1)
return true;
if(s.charAt(0) == s.charAt(s.length()-1))
return check(s.substring(1, s.length()-1));
return false;
}
public static void main(String[]args)
{
Scanner input = new Scanner(System.in);
System.out.print("Enter Number to check: ");
int num=input.nextInt();
String number = Integer.toString(num);
if(check(number))
System.out.println(number + " is a palindrome");
else
System.out.println(number + " is not a palindrome");
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.