Divisions using Arraylists Exercise: Using Arraylists create a program that makes divisions between two very large numbers (numbers greater than 10 digits).


I did it (the code works), but could my code be improved?

public class Main {

    static void division(List&lt;Integer&gt; lista, List&lt;Integer&gt; listb) {

        List&lt;Integer&gt; listResult = new ArrayList&lt;&gt;();

        if (lista.size() &lt;= 10 || listb.size() &lt;= 10) {
            System.out.println("The numbers must be bigger than 10");
        } else {double a = 0, j = 0;
            String Stringnumber = "";
            String Stringnumber2 = "";

            for (int number : lista) {
                Stringnumber += String.valueOf(number);
            }

            for (int number : listb) {
                Stringnumber2 += String.valueOf(number);
            }

            double test = Double.parseDouble(Stringnumber2);
            double test2 = Double.parseDouble(Stringnumber);

            double dividend = 0, divisor = 0;

            if (test &gt;= test2) {
                dividend = test;
                divisor = test2;
            } else {
                dividend = test2;
                divisor = test;
            }

            for (int i = 9; i &gt; 0 &amp;&amp; j != 1; i--) {
                if (i * divisor &lt;= dividend) {
                    listResult.add(i);

                    a = dividend - (i * divisor);
                    if (a &gt;= divisor) {
                        i = 9;
                    } else {
                        j = 1;
                    }
                }
            }

            System.out.println("The result is:");
            for (int i = 0; i &lt; listResult.size(); i++) {
                System.out.println(listResult.get(i));
            }

        }
    }

    public static void main(String[] args) {

        Scanner x = new Scanner(System.in);

        List&lt;Integer&gt; lista = new ArrayList&lt;&gt;();
        List&lt;Integer&gt; listb = new ArrayList&lt;&gt;();

        System.out.println("Give a number");
        for (char digit : x.nextLine().toCharArray()) {
            lista.add(digit - '0');
        }

        System.out.println("Give another number");
        for (char digit : x.nextLine().toCharArray()) {
            listb.add(digit - '0');
        }
        x.nextLine();

        division(lista, listb);
    }

}
At first, I thought that you were going to implement division of two integers, each represented as a list of digits.  But then, you simply concatenate all of the elements of each operand to be parsed as a double.  If you're going to cheat on the arithmetic using the built-in floating-point support, then what's the point of the exercise?  In fact, it doesn't even care whether you pass in an ArrayList of individual digits {1, 2, 3, 4, 5} or an ArrayList of one element {12345} — either way, it all gets stringified and parsed as 12345.0d.