Hope you learned a bit about using println for debugging.
I overlooked the static at first or this might have been a bit shorter.
Type: Posts; User: Norm
Hope you learned a bit about using println for debugging.
I overlooked the static at first or this might have been a bit shorter.
Did you notice that ALL the variables in the Enemy class are static?
When did you last look at the code?
Look at the code in post#1
What do you see when you look at the print out? It looks like there is only one instance of the class being put into all the slots.
Do you know what it means when a variable is defined as static?
Little bits of code aren't useful to anyone for finding the problem in your code. As I've said many times before: You need to print the whole array after ANY updates to it. After every update to...
Why does the print out of the whole array show null in elements 4,5,6 ?
Those slots had values when you printed them individually, but show null in post#13 when the contents of the whole array is...
If you want to find and fix the problem, you need to print out enough to show you where the problem is.
Did you see this in my last post? Can you explain how the code printed elements 4-6 when...
You need to print the whole array after ALL updates to it. If you ever get good data into the array, there should be some place in the programs execution where the contents of the array is changed...
What is the value of that index? What is the contents of the array at that index as shown by the printout?
To make the printout of the array more readable add a toString() method to the Enemy...
See post#4
If the code that is changing elements in the array has a problem, then you need to print out the contents of the array every time a change is made to catch where the problem is.
Does...
Add some more printlns to show all updates to the array
also print out the contents of the whole of the array occasionally.
A bug in the logic. Add more printlns to show the array's contents...
Print out the index and the contents at that index and the whole array occasionally.
Be sure to have unique id Strings in the print out so you know which println() has printed what line:
...
To debug this problem you'll probably need to show how all the variables are used and changed so you can catch where in the logic the program is going wrong.
Try debugging the code by adding lots of...
Can you post the program's output and add some comments that show what the problem is.
What does the ^ notation mean?