Here you can find the source of splitDigits(long input)
Parameter | Description |
---|---|
input | The number for which digits need to be collected |
static ArrayList<Integer> splitDigits(long input)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; public class Main { /**// ww w . j ava 2s . com * Converts an integer into an Integer array that has individual digits * * @param input * The number for which digits need to be collected * @return Array of Integer that represent all digits that make the number, * in same order, i.e. 123 = {1,2,3} */ static ArrayList<Integer> splitDigits(long input) { ArrayList<Integer> digits = new ArrayList<Integer>(); String digitsString = Long.toString(input); for (int i = 0; i < digitsString.length(); i++) { String subStr = digitsString.substring(i, i + 1); digits.add(Integer.parseInt(subStr)); } return digits; } }