从控制台读取数字并检查它是否是回文数字
/* *来 自 n o w j a v a . c o m */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) { System.out.println("Enter the number to check.."); int number = 0; try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); number = Integer.parseInt(br.readLine()); /* from N o w J a v a . c o m - 时 代 Java*/ } catch (NumberFormatException ne) { System.out.println("Invalid input: " + ne); System.exit(0); } catch (IOException ioe) { System.out.println("I/O Error: " + ioe); System.exit(0); } System.out.println("Number is " + number); int n = number; int reversedNumber = 0; int temp = 0; while (n > 0) { temp = n % 10; n = n / 10; reversedNumber = reversedNumber * 10 + temp; }