Closed ding-ma closed 3 years ago
Hi, the problem is that you are using the same instance of AionList for all map values. So when you clear the content of tmp, all the references to it are also cleared. Instead of using the same tmp list and clearing it every time, try creating a new ArrayList inside your for loop and remove the clear method call.
Even with a new list inside it does not work. I have tried both. It would work in plain old java
By putting a break point at the end of the loop and analyzing the content of that map
That's because you are still clearing the list. There is no need for that.
Ah true. Thanks!
In the following piece of code, I'm trying to map a 2d array into an AionMap by iterating through it.
Update: this implementation does not either. Creating a new object at every loop doesn't do the trick.
However, if you execute the code, the content of this AionMap is null. It is an issue between the AionList
tmp
, how it is cleared, and its reference within the AionMap.The only way I found the fix the issue is by using a helper function as show bellow and setting each variable to an element of the map as show in the second code block.