我理解成这样- /*
- 思路:先将int转成字符串,然后再转char数组,再转int。
- */
- class ArrayDemo
- {
- public static void main(String []args){
- int a = 123456;
- int b[] = toIntArray(a);
- for(int x=0;x<b.length;x++){
- System.out.println(b[x]);
- }
- }
- public static int[] toIntArray(int a){
- char []s = (a+"").toCharArray();
- int b[] = new int[s.length];
- for(int x=0;x<s.length;x++){
- b[x] = Integer.valueOf(s[x]+"");
- }
- return b;
- }
- }
复制代码
|