Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Eclipse Java Development User Guide
Previous Page Home Next Page

Generate toString() dialog

The Generate toString() dialog provides means to include specific member fields and methods in generated toString() method.

Use Generate toString()... from the Source menu or the context menu on a selected type or on a text selection in a type.

The members to be considered for inclusion in the toString() output are:

  • fields (non-static)
  • argument-less methods (non-static, non-void)
  • inherited fields and methods (fulfilling adequate conditions)

When pressing OK, the toString() method printing out all selected members and eventually helper methods are created.




Select fields and methods to include in the toString() method

For convenience, members are divided into up to four groups: Fields, Inherited fields, Methods and Inherited methods. Checking or unchecking a group affects the state of all it's members. Only fields which are non-transient and not inherited.

Select All

Select all fields and methods.


Deselect All

Deselect all fields and methods.



Move the element with focus up the list. A member can be moved only within its group. Groups can also be moved.



Move the element with focus down the list. A member can be moved only within its group. Groups can also be moved.


Insertion point

Defines where in the type body the generated methods are inserted. If a method already exists in a class and is overwritten, its position will not be changed (this option will have no effect).

Last member or location of the cursor position if invoked from editor

Generate method comments

Controls whether a comment is added to the created toString() method. Generated comment just points to a javadoc comment for java.lang.Object#toString().


String format

Defines which template is used to format the toString() output. A template determines what information about a class is added, how the fields are separated, and so on. For more information about templates, see toString() generator: format templates topic.

Default template


Opens a dialog that lets you add, remove or change string format templates (see above).


Code style

Defines the method code style, that is what libraries/mechanisms it uses to create output. For more information, see toString() generator: code styles topic.

String concatenation


Opens a dialog that lets you configure more options related to selected code style. Currently this button is only active for Custom toString() builder code style.


Skip null values

Controls whether the toString() method skips members that have no value (nulls). How it is accomplished depends on selected code style (see above).


List contents of arrays instead of using native toString()

Controls whether the toString() method lists items contained by arrays instead of using their default toString(). See toString() generator: listing content for details.


Limit number of items in arrays/collections/maps

Controls whether the toString() method limits the number of elements printed for arrays, Collections and Maps, and what the limit is. It doesn't work for arrays if "Ignore arrays' default toString()" option is off. See toString() generator: listing content for details.


Related reference

Source actions
toString() generator: format templates
toString() generator: code styles
toString() generator: content listing

  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire