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 (Retired) Meet Objects Creating Classes

Alexander Nowak
Alexander Nowak
498 Points

Why do we need two tabs, Example.java and PezDispenser.java ?

We have only used one 'tab' in the past, why are we now using two?

Thanks guys

1 Answer

Kevin Faust
Kevin Faust
15,353 Points

Hey Alexander,

If you were to keep all your code in one tab (in one class file) , as you write more and more your code will get harder to read and to navigate. It is primarily done so that we can separate different class files and keep their properties/methods apart from other classes. And then we can simply bring all of them together by calling their methods and stuff in our main java file. In our case, that would be the Example.java file.

I hope that helped!

Happy coding,

Kevin