Welcome to the Treehouse Community
Looking to learn something new?
Nasim Zoubeiri2,652 Points
Running 'javac Hangman.java' seems to compile all '.java' files
Why don't we have to also compile Game.java and Prompter.java in the command line javac step? Are they automatically compiled when compiling Hangman.java because Hangman instantiates objects of those classes?
I'd image the javac command would look more like: clear && javac Hangman.java Game.java Prompter.java && java Hangman
Dennis Mårtensson7,400 Points
I suppose it is as you say, when you tell the compiler to compile one file, it automatically compiles all other files relating to the file you are implicitly compiling. I'm no expert on the subject though, but that's a reasonable explanation!
Craig DennisTreehouse Teacher
Yeah it is because you are requiring the other java classes by importing them. When compilation happens it compiles the files it needs, which in this case is Game and Prompter.
That make sense?