Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Objects Meet Objects Methods

vikas pal
vikas pal
11,252 Points

Why we use get?

Why we use the get for making new method is it a naming convension?

1 Answer

Yes, naming methods getVariable and setVariable when those methods are used to get or set an instance variable is a naming convention. You don't have to name your methods this way, but it helps other developers understand at a glance what the method is for.

vikas pal
vikas pal
11,252 Points

Thnks Livia for clearing my doubt.