call function with same name + number

So I have 30 different functions all like this

public void level23()
		theGame.levelSelected = 23;

This is what is called to setup the next level in game. I was wondering if there was a way for me to call this in a retry button by using something like this with theGame.levelSelected being an int

level + theGame.levelSelected();

this would save a rather long switch.

Well, first of all, you shouldn’t have 30 different functions to change a single integer. Why not literally just change the integer?

Can you not type this every time you need to load a new level?

theGame.levelSelected = 23;

And if anything, you can do this:

public void LevelThing(int num){
   theGame.levelSelected = num;
   // Then do other things here if you want to.