answersLogoWhite

0


Best Answer

import java.io.*;

public class chuva

{

public static void main(String[] args) throws Exception

{

BufferedReader x = new BufferedReader(new InputStreamReader(System.in));

int rem, quo, rev=0;

System.out.println("Enter a number: ");

int a = Integer.parseInt(x.readLine());

int b=a;

for(int ctr=0; ctr<=a; ctr++)

{

rem = a%10;

a = a/10;

rev = rev*10 +rem;

ctr=0;

}

System.out.println(+rev);

if(b==rev)

System.out.println("Palindrome");

else

System.out.println("Not Palindrome");

}

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

You can use the StringBuffer class. Convert the integer to a StringBuffer, use a second StringBuffer and copy the value, turn it around (StringBuffer has a special method for this), and compare if they are equal.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Java programming to check a digit number is palindrome or not?
Write your answer...
Submit
Still have questions?
magnify glass
imp