Thomas James
Thomas James
4,990 Points

constructor Game in class cannot be applied to given types

Hi all,

In Prompting for guesses video I keep getting the following error:

treehouse:~/workspace$ javac && java Hangman
Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m error: constructor Game in class Game cannot be applied to given types;
Game game = new Game("treehouse");
required: String,String,String
found: String
reason: actual and formal argument lists differ in length
1 error

I think I understand why I am getting this error. My game classes has a constructor with three parameters, however when I create a game object in my hangman class I am only giving it one parameter, this being the answer. How do I fix? Unless I am being silly I don't think the video differs to my code. Please help

1 Answer

Tom Achki
Tom Achki
3,660 Points

I do not remember the video but if you have 3 parameters required for constructor, you have to provide 3 parameters when you create an object. You can change the constructor to accept 1 parameter. Show me your code if you want more specific answer.