Take NR's point. People here and in the other forum
need to know if you post the same question on two websites. Also work out how the
code tags work; they are similar to the other forum. I corrected your tags this time. I also added code tags round your desired output because the tags also improve the appearance of outputs. Do you really want the output double‑spaced?
I am afraid I don't like your solution because:-
1: You have too much code in the main method, and you are actually writing procedural code rather than object code.2: Your loop in line 21 destroys information. If you get that loop to run, you will convert your array to {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}.Please look very carefully at the loop in line 16 and work out how many times it will run.