Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        Integer num = 12345;
        Integer[] digits = getDigits(num.toString());
        System.out.println(Arrays.toString(digits));
    }

    public static Integer[] getDigits(String number) {
        List<Integer> digits = new ArrayList<Integer>();
        for (int i = 0; i < number.length(); i++) {
            int j = Character.digit(number.charAt(i), 10);
            digits.add(j);
        }
        return digits.toArray(new Integer[] {});
    }
}