Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Objects Delivering the MVP Wrapping Up

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?