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) Harnessing the Power of Objects Helper Methods and Conditionals

Aditya Puri
Aditya Puri
1,080 Points

What are we trying to not repeat?

I understood everything he taught us in the video....we made a new methid which checks if the dispenser is empty and we used it in our main class.

BUT he keeps saying that we don't wanna repeat something...and at the end he congratses us for not repeating something,,,what did we not repeat??

1 Answer

Josh Benner
Josh Benner
5,554 Points

We prevented ourself from repeating writing the same code over and over again. Not only does putting repeated functionality make code cleaner, it makes it easier to modify and maintain and it uses less memory. Imagine that we checked the dispenser if it was empty or not a lot. Writing code in a main function would get tedious

Aditya Puri
Aditya Puri
1,080 Points

oh so we didn't write code in the main function and wrote it in the class file?