I have a series of character arrays storing level data for a game named LEVEL_1, LEVEL_2 etc. I have to make the program advance to the next level when complete, and so I made a string
levelString = ("LEVEL_" + nextLevelNumber)
When I try to then use
advanceToLevel(levelString);
to advance to the next level array it obviously does not work because array and string are incompatible.
Is there a way to make it call the array by string value, or have I missed a simpler way to advance to the next level without an if statement for each level?
I'm quite new to Java, so it needs to be simple.
Edit: this question is not a duplicate. I am asking how to advance to the next array, having tried to use string concatenation with a variable. I am looking for an alternative solution.