I've got this one dimensional array:
and than I do stuff like this with it:
No problem. But than I go on on doing a small trick:
Thank I think it would be nice to admire what I've don, so I go on printing the array out:
and, to my surprise I get result:
10 20 30 40
wouldn't have I destroyed the previous array od int with values 10 and 20 by calling new int???
Your insight as always will be greatly appreciated.
you can dress it in a class if you like but that's all there is.
I suppose I am right and whoever wrote the test has no clue. I see no way there could be any other result as 0 0 30 40 .
Piet Souris wrote:
Well, the subject IS about arrays, and the title was so inviting, it drew my attention. So, I think the title is perfect.
I felt, Array showing strange output or Array not showing correct output or Array output problem or Previous array reference not assigning new array reference? or Reassignment of array reference not working ? these would have been more expressive so anyone who is having trouble related array output then they can check this thread. I felt subject line should be useful not only to the people who wants to answer but also who searches for similar question when they get similar kind of problems, here array output.
Use A Meaningful Subject Line wrote:A subject like "Problem with Swing" or "JPanel" doesn't motivate many people to take a closer look, whereas "difference between Component and Container" (hopefully posted in the Swing forum) will attract exactly those people who can - and like to - answer