Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Objects Delivering the MVP Wrapping Up

toni chen
toni chen
3,865 Points

How do i store the Highscore ?

so everytime when we run the program, it will show the current player highscore,

Store it in a file, dog

1 Answer

Sławomir Lasik
Sławomir Lasik
7,792 Points

Well, the best way is to store the highScore static field in the file and update it each time the new highScore is achieved.

Like in some static method in Game.java that is called in Hangman.java before for example object creation

    if (args.length == 0) {
        System.out.println("Usage : java Hangman <answer>");
        System.err.println("Invalid usage!");


    Game game = new Game(args[0]);

But for now I think it's beyond scope of what it is learned here up to now. ;)

Anshuman Tripathy
Anshuman Tripathy
868 Points

@Sławomir Lasik

What do you initialize the highScore static field to while defining it in Game.java?

And everytime you compile the file won't it get initialized to that value?

What difference will it make even if you update it everytime?