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 trialAdam Brown
1,893 PointsWhat is the function of each java file?
With the three java files, what is the function of each one? This is all new to me, so any very basic explanation or clear explanation would greatly help. What is the reason of having these three separate files? Since these are all in the same folder, is that why I am able to work with them together? Ho would you work with two java files together in different locations? I just realized how my one question led to many more. Thanks!
1 Answer
Craig Dennis
Treehouse TeacherHa! Questions always lead to more, that's a good thing!
You always want to separate your code logically. I'm assuming you are in Java Objects. In this case one file was for the blueprint, or class definition, and one was for running the program.
You are right about the access. Files in the same folder are in the same package. You can create packages by making new folders. You use them by importing. See the import statement at the top of the Example file? Console is in the java.io package.
We explore packages in the Java Data Structures course.
That help?
Adam Brown
1,893 PointsAdam Brown
1,893 PointsSo I understand now to have one file as the "blueprint" and the other for actually running the program, but there is a third one as well. I have three files: Hangman, Prompter, and Game. So I believe Game would be the blueprint and hangman will be for running the program? Then there is a third, prompter, but since I am early on in making this, I see now that it will be easier to understand once more is added to the Prompter and Game java files. Thanks.
Craig Dennis
Treehouse TeacherCraig Dennis
Treehouse TeacherThings making sense now Adam Brown ?