Java Java Objects Meet Objects Methods

vikas pal
vikas pal
8,545 Points

Why we use get?

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

1 Answer

Livia Galeazzi
PRO
Livia Galeazzi
Java Web Development Techdegree Graduate 19,906 Points

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
8,545 Points

Thnks Livia for clearing my doubt.