日期:2014-05-16 浏览次数:20624 次
public class getNum2 { public static void main(String[] args) { int to array of int int i1 = 12345; while (i1 >= 1) { System.out.println(i1 % 10); i1 /= 10; } }
package rnd; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class getNum { public static void main(String[] args) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try { System.out.println(get(Long.parseLong(br.readLine()))); } catch (NumberFormatException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public static long get(Long num) { String s = String.valueOf(num); byte[] by = s.getBytes(); byte[] by2 = new byte[by.length]; int t = by.length - 1; for (int i = 0; i <= by.length - 1; i++) { by2[t] = by[i]; t--; } return Long.parseLong(new String(by2)); } // 这个是在网上找到的方法,不过缺陷是要确定位数。 public static long get2(Long num) { String s = String.valueOf(num); String s2; System.out.print("请输入你想逆转的数字"); Scanner input = new Scanner(System.in); s2 = s.replaceAll("([0-9])([0-9])([0-9])([0-9])([0-9])", "$5$4$3$2$1"); return Long.parseLong(new String(s2)); } }