IntelliJ IDEA 2021.3 Help

Add new field or constant

Item

Description

Visibility

Select the desired visibility modifier.

Type

Specify the type of the new field. Note that code completion works here. As you type, the suggestion list shrinks to show the matching options. Non-existent type is marked as a syntax error.

Name

Specify the name of the new field.

Initializer

Specify the initial value of the new field. Note that such value should correspond to the declared type. For example, if the type is String, the suggested initializer should be enclosed in quotes.

Note that code completion works here. As you type, the suggestion list shrinks to show the matching options. Non-existent type is marked as a syntax error.

Static

Add static to the field declaration.

Final

Add final to the field declaration.

Preview

This read-only area shows the draft declaration as you fill in the dialog fields.

Last modified: 01 August 2022