Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autogeneration of Get & Set methods?

Tags:

java

I think the creation of holder classes, classes with just attritutes, get methods and set methods can be autogenerated. I understand that Eclipse is a defacto "standard" Java IDE these days. Does Eclipse do this? Do other IDEs?

I'm guessing the only reasons for making dedicated data holding classes instead of using HashMaps is to have mixed datatypes in a more visible/safter way and for the occasion when you want to DO something to the data when inserting it or retrieving it. Thoughts?

like image 711
Steve Avatar asked Dec 30 '11 18:12

Steve


1 Answers

Yes. Eclipse Does this. To generate setter/getter, select the class in package explorer, right click -> Source -> Generate getter/setting.

Netbean also does this. Right click anywhere inside your class -> insert code-> setter/getter.

we do that to encapsulate the implementation details. you can find more explanations Why use getters and setters

like image 58
neo Avatar answered Oct 03 '22 23:10

neo