Last Updated: January 21, 2022
·
103.8K
· stathisg

Auto-generate get, set, & constructor functions in NetBeans

If you're using NetBeans, the following will save you a lot of time: You can automatically generate get and set functions for your variables, as well as constructors in a matter of seconds. The following works for both Java and PHP (but I assume it's working for other languages as well).

Just point the cursor at the point where you want the generated code to appear, and press Alt + Insert (or select Source -> Insert Code). The following menu will appear, where you can choose to generate whatever you want:

Picture

You can select the variables you want the getters/setters to be generated for, as well as the naming style of the functions:

Picture

After you click OK, you'll end up with something like the following:

Picture

The same process will work for the constructor, as well as for any other options present in the menu (depending on the language).