GameState code organisation and class design.

In my game I want to organise the code very well. Of course.
The game is built with LWJGL.
When the game starts, the main menu appears, in that menu you can open the settings, the list of saved games, etc.
When a saved game is selected and it opens, the actual game starts. (3d world… etc.)
This are gamestates.

Now I’m not sure how to design this the best way.
My current approach is as follows:

The main menu, settings screen, saves screen, and the actual game are gamestates.
So I just make a class like GameState. That class implements the methods render() and handleInput().
The disadvantage is that I have to choose the gamestate active current in the gameloop, and then do the rendering and input handling for that active gamestate. This means the gameloop does something that will always costs some performance.
To solve this, I make a member variable in the class that has the gameloop, and just set the value of that variable as the active GameState. Now I don’t have to check things in the gameloop and just use the variable, and call render() and handleInput() on it.
When it switches between GameStates, it just changes the GameState that’s stored in the variable.

My questions:

  1. How do you handle a game state implementation?
  2. Is my approach a good idea?

While the performance loss is negligible, your approach is alright.
I have View classes, because the wording is clearer for me.

I do pretty much identical to you’ve described.

Cheers,

Kev