Java Reseting alll values in the program

Hi, I am working on this program where at the end of the game I ask the user if they want to play again.  If they say yes, I need to start a new game.  I made a restart()

public void restart(){
            Game g = new Game();

However when I call this method some of the values in my program still at what they were during the previous game.

Is there a game to just clear everything and create an new instance of the game with all the default values?
Who is Participating?
The reason we ask this, is because the static variables "follow" the class, and not the instantiated objects.

A static class variable will not change as you create instances of the class.
Where are you storing these values? You should put them as attributes for the Game class (but not static).
It is hard to say but that variables that stay at their previous values are not just static to class?
ubuntuguyAuthor Commented:
Hi sorry I was making a mistake.... I was calling the reset method not the restart one... lol.. sorry.... although I learned something about static variables  in this thread that i didnt know
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.