Why can I create multiple instances with the same name in a loop?

前端 未结 4 960
滥情空心
滥情空心 2021-01-28 05:39

I don\'t understand why this works and I hope somebody can explain it to me. Here is an example:

TestObject array[] = new TestObject[10];
for(int i= 0; i <= 1         


        
4条回答
  •  说谎
    说谎 (楼主)
    2021-01-28 06:22

    it's the scope of object problem. every iteration has its scope let's say they are not the same object at all

提交回复
热议问题