Originally Posted by
112297
I have 3 arrays...The numList array accepts input values from the console. The 2nd array listCopy has the values from the numList array deep copied into it...I did that so I could use it to compare with the numList array to see how many duplicate numbers are entered...The 3rd array numSame, is supposed to hold the values of the number of duplicates...I use Arrays.sort to print out the numbers in increasing order...I understand everything that's going on except the error I'm getting...It keeps saying out of bounds on the line where the variable 'counter' is attempting to assign it's value to list3[k] ...it's somethings about the third array...I'm stumped..
The program outputs zero because the numSame method is calling the 3 arrays you declared at the start. In other words, they're empty, so your if-statement is evaluating whether 0 equals the array length (100).
Why not just search for duplicates directly from the numList array? Instead of checking for duplicates, the numSame method increments a counter if values from 1 array equal the length of another array, where both arrays have the same length. The third array stores values from the counter, which I'm not understanding the reason for. Your program isn't complete and I suggest you lay out the logic, then start over.