# 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.

Option | Description | Default
--- | --- | ---
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 its members. | Only fields which are non-transient and not inherited.
Select All | Select all fields and methods. | n/a
Deselect All | Deselect all fields and methods. | n/a
Up | Move the element with focus up the list. A member can be moved only within its group. Groups can also be moved. | n/a
Down | Move the element with focus down the list. A member can be moved only within its group. Groups can also be moved. | n/a
Sort | Sort elements in every group in lexicographical order. | n/a
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()`. | off
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
Edit... | Opens a dialog that lets you add, remove or change string format templates (see above). | n/a
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
Configure... | 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. | n/a
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). | off
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. | off
Limit number of items in arrays/collections/maps | Controls whether the toString() method limits the number of elements printed for arrays, `Collection`s and `Map`s, 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. | off

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