Java ArrayList Create getArrayListFromInt(int number)

Here you can find the source of getArrayListFromInt(int number)

Description

get Array List From Int

License

Apache License

Declaration

public static ArrayList getArrayListFromInt(int number) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;

public class Main {
    final static int[] sizeTable = { 9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999,
            Integer.MAX_VALUE };//  w  ww  .j  a  v a 2s . c  om

    public static ArrayList getArrayListFromInt(int number) {
        ArrayList<Integer> list = new ArrayList<>();
        int length = stringSize(number);
        for (int i = length - 1; i >= 0; i--) {
            list.add(0, number % 10);
            number /= 10;
        }
        return list;
    }

    public static int stringSize(int x) {
        for (int i = 0;; i++)
            if (x <= sizeTable[i])
                return i + 1;
    }
}

Related

  1. getArrayList(final Object o, final Class clazz)
  2. getArrayList(List list)
  3. getArrayList(Map map, Object obj)
  4. getArrayList(String[] args)
  5. getArrayListForArray(Object[] rowData)
  6. getArrayListFromString(String wordSequence, String separator)
  7. newArrayList()
  8. newArrayList()
  9. newArrayList()