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!
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
Bob Allan10,900 Points
Why do Example.java and PezDispenser.java run at the same time?
In the Pez dispenser exercises, I don't understand why both files run when only Example.java is compiled/ran. Are they linked somehow?
How would I run both of them in an IDE like jGrasp or Eclipse?
Thanks in advance for your help.
William Bauer1,178 Points
So, in Java when compiling - your system will look for the method (public static void Main()). So this means that the class with this method in it is the main class for your program. The PezDispenser is connected with Example by this code: PezDispenser dispenser = new PezDispenser();
Here you create a NEW dispenser which is coming from the class PezDispenser. I hope this made sense. Enjoy the rest of your day!