For example, an integer of 1234 and an integer of 4321 is output. The problem is excerpted from <C language example development>
Algorithm Implementation is not good enough.
package com.jue.numberreverse;public class NumberReverse {/** * @param args */public static void main(String[] args) {// TODO Auto-generated method stubint old = 123456789;System.out.println("old:" + old);System.out.println("new:" + getReverseDataNumber(old));}public static int getReverseDataNumber(int old) {final int length = getDataLength(old);final int[] datas = new int[length];int tempdata = old;for (int i = 0; i < length; i++) {int dataInIndex = tempdata / getMultipleData(length - 1 - i);datas[i] = dataInIndex;tempdata -= dataInIndex * getMultipleData(length - 1 - i);}int newdata = 0;for (int i = 0; i < datas.length; i++) {newdata += datas[i] * getMultipleData(i);}return newdata;}private static int getMultipleData(int indexInNumber) {if (indexInNumber == 0) {return 1;}return 10 * getMultipleData(indexInNumber - 1);}public static int getDataLength(int data) {return String.valueOf(data).length();}}