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
Melodie 1
3,931 PointsWhat are the benefits of private methods and when to use them?
Hi everyone
i'm currently learning java , and i've seen many pieces of code where some classes have almost only private methods , but i can't understand what is the benefits of such a design , aren't method there to be called ? And if they are beneficial , when should i use them ?
1 Answer
hamdi ismail
Courses Plus Student 8,927 Pointsprivate method can always be changed safely, because you know for sure that is called only from the own class, no external classes are able to call a private method.So having a private method is always good and public method anyone could call that method . i hope it help