O'Reilly logo

NetBeans IDE 8 Cookbook by Rhawi Dantas, David Salter

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a constructor

When creating a class that maintains any state (that is almost any class that has class members), it can be very useful to create a constructor that can perform any required initialization.

Creating constructors is not tricky; however, NetBeans provides a handy shortcut to save time and increase developer productivity.

Getting ready

First we will need to create a new project, so please refer to the recipes in Chapter 1, Using NetBeans Projects, for creating Java projects. To help follow this recipe, when creating a project, enter CreatingConstructors as the project name.

How to do it…

When the Projects explorer shows the CreatingConstructors project, expand the CreatingConstructors node if it is not already expanded.

We will now ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required