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 toString() method

A useful technique to aid debugging Java applications is to add a toString() method onto a class so that useful information can be output to help describe the class. Typically, a toString() implementation would output any ID that an object has together with the description of the object. NetBeans provides facilities to allow developers to easily add and customize toString() methods within classes.

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 CreatingToString as the project name and ensure that a main class called com.davidsalter.cookbook.creatingtostring.CreatingToString ...

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