Your issue is Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10
because you use array and fixed the size by 10 and you try to add more than 10 elements int this array,
please read this arrayindexoutofboundsexception for more details.
you have to use array list instead of array
ArrayList<Integer> arr = new ArrayList<Integer>();
arr.add(num); // use this add new item to array
solved Error in JAVA code while running it [duplicate]