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 property

In this recipe, we'll see how we can create properties directly within a class without having to first add fields to the class and then add accessors for the fields.

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 CreatingProperties as the project name and ensure that a main class called com.davidsalter.cookbook.creatingproperties.CreatingProperties is created.

How to do it…

To show how to create properties within a class, let's first create a class to represent a customer and then add some properties to the Customer class:

  1. Right-click on the CreatingProperties project, ...

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