Dave Tolls wrote:num_of_Toppings is the total of one and two (7 in this case).
Consequently when you use it to generate the index to use for the arrays it has a pretty high chance of producing a number that's too large.
Campbell Ritchie wrote:Delete lines 9‑12. Use the .length fields throughout, or array1.length + array2.length for the total.
Campbell Ritchie wrote:. . . This is what you started off with:- . . .And this is my corrupted version:- . . . If you are doing arithmetic with + in the same line as String concatenation, put () round the arithmetic. . . . .