I have a quick question. I have an integer array in java that needs its length to vary throughout the class. Specifically, I need it to increase by one in certain situations. I tried it like this.
sbgHeadX = new int[ numberOfSBG ];
I would increase the integer variable numberOfSBG when I needed to, but I don’t think this works. Is there any other way?
I would suggest you use an ArrayList as you won’t have to worry about the length anymore. Once created, you can’t modify an array size:
(Source)