I keep getting this error.
First call to assembleArray():
Enter the first integer:
42
Enter the second integer:
427
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
at filename.assembleArray(filename.java:151)
at filename.main(filename.java:18)
but when I put something like the following it works:
First call to assembleArray():
Enter the first integer:
1328
Enter the second integer:
456
The resulting array has 4 elements as follows,
[ 0 2 3 0 ]
line 151:
finalArray[ finalIndex ] = finalNum;
line 18:
lastArray = assembleArray (firstA, firstB);
I know it has something to do with the index but I dont know how to fix it because I can't set the index since it depends on user input.
For the resulting array, the first number is the sum of all odd one-digits, second number is the sum of all even 10-digits, and the third number is the sum of all multiples of 3.