llms.txt: machine-readable documentation index. Markdown version of this page is also available.

IntelliJ IDEA 2026.3 Help

Code Style. Java

Use this page to configure formatting options for Java files. When you change these settings, the Preview pane shows how this will affect your code.

Tabs and Indents

Item

Description

Use tab character

Use the Tab key for indentation. When the checkbox is cleared, IntelliJ IDEA uses spaces instead of tabs.

Smart tabs

  • If this checkbox is selected, the indentation for nested code blocks will use tabs and spaces as needed, while alignment indentation will use only spaces.

  • If this checkbox is cleared, only tabs are used. This means that a group of spaces that fits the specified tab size is automatically replaced with a tab, which may result in breaking fine alignment.

The Smart tabs checkbox is available if the Use tab character option is enabled.

Tab size

In this field, specify the number of spaces included in a tab.

Indent

In this field, specify the number of spaces to be inserted for each indent level.

Continuation indent

Specify the indentation for lines that continue from the previous line, making it clear that they are part of the same statement or block of code. Continuation indents are used when a single statement is too long to fit on one line.

Keep indents on empty lines

If this checkbox is selected, IntelliJ IDEA will keep indents on the empty lines as if they contained some code.

If this checkbox is cleared, IntelliJ IDEA will delete the tab characters and spaces.

Label indent

In this field, specify the number of spaces to be inserted at the next line before a label statement.

Absolute label indent

If this checkbox is selected, label indentation is counted as an absolute number of spaces. Otherwise, label indentation is counted relative to previous indent levels.

Do not indent top level class members

Select this checkbox to have top level class members located at the class declaration indentation level.

Use indents relative to expression start

Use this checkbox to switch between the two possible indentation behaviors:

  • If this option is disabled, code blocks will be aligned with the nearest ancestor block that begins on a new line.

  • If the option is enabled, the blocks of code will be formatted in columns.

Spaces

Select or clear the checkboxes to insert, not to insert, or remove spaces in various contexts.

Before parenthesis

Item

Example

Method declaration parentheses

If selected, a space is inserted before the opening parenthesis in method declarations. Otherwise, no space is inserted.

public void foo (int x, int y) {}
public void foo(int x, int y) {}

Method call parentheses

If selected, a space is inserted before the opening parenthesis in method calls.

Otherwise, no space is inserted.

System.out.print (a);
System.out.print(a);

'if' parentheses

If selected, a space is inserted before the opening parenthesis in if statements. Otherwise, no space is inserted.

if (0 < x && x < 10) {}
if(0 < x && x < 10) {}

'for' parentheses

If selected, a space is inserted before the opening parenthesis in for loops. Otherwise, no space is inserted.

for (int i = 0; i < x; i++) {}
for(int i = 0; i < x; i++) {}

'while' parentheses

If selected, a space is inserted before the opening parenthesis in while loops. Otherwise, no space is inserted.

while (x != y) {}
while(x != y) {}

'switch' parentheses

If selected, a space is inserted before the opening parenthesis in switch statements. Otherwise, no space is inserted.

switch (e.getCode()) {}
switch(e.getCode()) {}

'try' parentheses

If selected, a space is inserted before the opening parenthesis in try statements. Otherwise, no space is inserted.

try (Res r1 = getResource(); Res r2 = null) {}
try(Res r1 = getResource(); Res r2 = null) {}

'catch' parentheses

If selected, a space is inserted before the opening parenthesis in catch blocks. Otherwise, no space is inserted.

catch (MyException e) {}
catch(MyException e) {}

'synchronized' parentheses

If selected, a space is inserted before the opening parenthesis in synchronized blocks. Otherwise, no space is inserted.

synchronized (this) {}
synchronized(this) {}

Annotation parameters

If selected, a space is inserted before the opening parenthesis of annotation parameters. Otherwise, no space is inserted.

@SuppressWarnings ({"ALL"})
@SuppressWarnings({"ALL"})

Deconstruction list

If selected, a space is inserted before the opening parenthesis in deconstruction patterns. Otherwise, no space is inserted.

case Rec (String s, int i) r -> {}
case Rec(String s, int i) r -> {}

Around operators

Item

Example

Assignment operators (=, +=, ...)

If selected, spaces are inserted around assignment operators in assignment expressions. Otherwise, no spaces are inserted.

int[] empty = new int[]{};
int[] empty=new int[]{};

Logical operators (&&, ||)

If selected, spaces are inserted around logical operators in logical expressions. Otherwise, no spaces are inserted.

public void checkValue() { if (0 < x && x < 10) { } }
public void checkValue() { if (0 < x && x < 10) { } }

Equality operators (==, !=)

If selected, spaces are inserted around equality operators in comparison expressions. Otherwise, no spaces are inserted.

while (x != y) {}
while (x!=y) {}

Relational operators (<,>,<=,>=)

If selected, spaces are inserted around relational operators in comparison expressions. Otherwise, no spaces are inserted.

if (0 < x && x < 10) {}
if (0<x &&x< 10) {}

Bitwise operators (&, |, ^)

If selected, spaces are inserted around bitwise operators. Otherwise, no spaces are inserted.

y += (y ^ 0x123) << 2;
y += (y^0x123) << 2;

Additive operators (+, -)

If selected, spaces are inserted around additive operators. Otherwise, no spaces are inserted.

x = f(x * 3 + 5);
x = f(x * 3+5);

Multiplicative operators (*, /, %)

If selected, spaces are inserted around multiplicative operators. Otherwise, no spaces are inserted.

x = f(x * 3 + 5);
x = f(x*3 + 5);

Shift operators (<<, >>, >>>)

If selected, spaces are inserted around bit shifting operators. Otherwise, no spaces are inserted.

y += (y ^ 0x123) << 2;
y += (y ^ 0x123)<<2;

Unary operators (!,-,+,++,--)

If selected, spaces are inserted around unary operators. Otherwise, no spaces are inserted.

x = y >= 0 ? arr[y] : - 1;
x = y >= 0 ? arr[y] : -1;

Lambda arrow

If selected, spaces are inserted around lambda arrows. Otherwise, no spaces are inserted.

Runnable r = () -> {};
Runnable r = ()->{};

Method reference double colon

If selected, a space is inserted around method reference double colons. Otherwise, no space is inserted.

Runnable r1 = this :: bar;
Runnable r1 = this::bar;

Before left brace

Item

Example

Class left brace

If selected, a space is inserted between the class name and the opening brace in class declarations. Otherwise, no space is inserted.

public class Main { }
public class Main{ }

Selecting or clearing the checkbox is relevant only when Braces placement for In class declaration is set to End of line on the Wrapping and Braces tab.

Method left brace

If selected, a space is inserted between the method parameters' list closing parenthesis and the opening brace in method declarations. Otherwise, no space is inserted.

public int add(int a, int b) { }
public int add(int a, int b){ }

Selecting or clearing the checkbox is relevant only when Braces placement for In method declaration is set to End of line on the Wrapping and Braces tab.

'if' left brace

If selected, a space is inserted between the conditional expression's closing parenthesis and the opening brace in if statements. Otherwise, no space is inserted.

if (0 < x && x < 10) { }
if (0 < x && x < 10){ }

Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.

'else' left brace

If selected, a space is inserted between the else keyword and the opening brace in if-else statements. Otherwise, no space is inserted.

if (x) { System.out.println("Hello from x!"); } else { System.out.println(y); }
if (x) { System.out.println("Hello from x!"); } else{ System.out.println(y); }

Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.

'for' left brace

If selected, a space is inserted between the conditional expression's closing parenthesis and the opening brace in for loops. Otherwise, no space is inserted.

for (int a : X) { System.out.print(a); }
for (int a : X){ System.out.print(a); }

Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.

'while' left brace

If selected, a space is inserted between the conditional expression's closing parenthesis and the opening brace in while loops. Otherwise, no space is inserted.

while (x != y) { x = f(x * 3 + 5); }
while (x != y){ x = f(x * 3 + 5); }

Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.

'do' left brace

If selected, a space is inserted between the do keyword and the opening brace in do-while loops. Otherwise, no space is inserted.

do { System.out.println("Count is: " + count); count++; } while (count <= 3);
do{ System.out.println("Count is: " + count); count++; } while (count <= 3);

Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.

'switch' left brace

If selected, a space is inserted between the conditional expression's closing parenthesis and the opening brace in switch statements. Otherwise, no space is inserted.

switch (e.getCode()) { }
switch (e.getCode()){ }

Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.

'try' left brace

If selected, a space is inserted between the try keyword and the opening brace in try blocks. Otherwise, no space is inserted.

try { get("x"); } catch (Exception e) { }
try{ get("x"); } catch (Exception e) { }

Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.

'catch' left brace

If selected, a space is inserted between the catch statement argument list and the opening brace in catch blocks. Otherwise, no space is inserted.

try { get("x"); } catch (Exception e) { }
try { get("x"); } catch (Exception e){ }

Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.

'finally' left brace

If selected, a space is inserted between the finally keyword and the opening brace in finally blocks. Otherwise, no space is inserted.

try { get("x"); } catch (Exception e) { } finally { }
try { get("x"); } catch (Exception e) { } finally{ }

Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.

'synchronized' left brace

If selected, a space is inserted between the synchronized keyword and the opening brace in synchronized blocks. Otherwise, no space is inserted.

synchronized (this) { switch (e.getCode()) { }
synchronized (this){ switch (e.getCode()) { }

Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.

Array initializer left brace

If selected, a space is inserted before the left brace of an array initializer. Otherwise, no space is inserted.

int[] empty = new int[] {};
int[] empty = new int[]{};

Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.

Annotation array initializer left brace

If selected, a space is inserted before the left brace of an array initializer. Otherwise, no space is inserted.

@SuppressWarnings( {"ALL"})
@SuppressWarnings({"ALL"})

Selecting or clearing the checkbox is relevant only when Braces placement for Other is set to End of line on the Wrapping and Braces tab.

Before keywords

Item

Description

'else' keyword

If selected, a space is inserted between the closing brace of an if block and an else/elseif keyword. Otherwise, no space is inserted.

if (x) { System.out.println("Hello from x!"); } else { System.out.println(y); }
if (x) { System.out.println("Hello from x!"); }else { System.out.println(y); }

'while' keyword

If selected, a space is inserted between the closing brace of a do block and the while keyword in do-while loops. Otherwise, no space is inserted.

do { System.out.println("Count is: " + count); count++; } while (count <= 3);
do { System.out.println("Count is: " + count); count++; }while (count <= 3);

'catch' keyword

If selected, a space is inserted between the closing brace of a try block and the catch keyword. Otherwise, no space is inserted.

try { get("x"); } catch (Exception e) { }
try { get("x"); }catch (Exception e) { }

'finally' keyword

If selected, a space is inserted between the closing brace of a catch block and the finally keyword. Otherwise, no space is inserted.

try { get("x"); } catch (Exception e) { } finally { }
try { get("x"); } catch (Exception e) { }finally { }

Within

Item

Description

Code braces

If selected, spaces within code braces are always inserted. Otherwise, spaces are never inserted.

Brackets

If selected, spaces within brackets are always inserted. Otherwise, spaces are never inserted.

x = y >= 0 ? arr[ y ] : -1;
x = y >= 0 ? arr[y] : -1;

Array initializer braces

If selected, spaces inside parentheses in array initializer expressions are always inserted. Otherwise, no spaces are inserted.

int[] numbers = { 1, 2, 3, 4, 5 };
int[] numbers = {1, 2, 3, 4, 5};

Empty array initializer braces

If selected, spaces are inserted within the braces of an empty array initializer { }. Otherwise, no spaces are inserted.

int[] empty = new int[]{ };
int[] empty = new int[]{};

Grouping parentheses

If selected, spaces inside grouping parentheses in complex expressions are always inserted. Otherwise, no spaces are inserted.

y += ( y ^ 0x123 ) << 2;
y += (y ^ 0x123) << 2;

Method declaration parentheses

If selected, spaces are inserted within method declaration parentheses. Otherwise, no spaces are inserted.

public void foo( int x, int y ){ }
public void foo(int x, int y){ }

Empty method declaration parentheses

If selected, spaces are inserted within the empty method declaration parentheses. Otherwise, no spaces are inserted.

Runnable r = ( ) -> { };
Runnable r = () -> { };

Method call parentheses

If selected, spaces are inserted within method call parentheses. Otherwise, no spaces are inserted.

System.out.println( "Hello, World!" );
System.out.println("Hello, World!");

Empty method call parentheses

If selected, spaces are inserted within the empty method call parentheses. Otherwise, no spaces are inserted.

switch (e.getCode( )) { }
switch (e.getCode()) { }

'if' parentheses

If selected, spaces inside parentheses in if statements are always inserted. Otherwise, no spaces are inserted.

for (int num : numbers) { if ( x ) { System.out.println("Hello from x!"); } else { System.out.println(y); } }
for (int num : numbers) { if (x) { System.out.println("Hello from x!"); } else { System.out.println(y); } }

'for' parentheses

If selected, spaces inside parentheses in for loops are always inserted. Otherwise, no spaces are inserted.

for ( int a : X ) { System.out.print(a); }
for (int a : X) { System.out.print(a); }

'while' parentheses

If selected, spaces inside parentheses in while loops are always inserted. Otherwise, no spaces are inserted.

while ( x != y ) { x = f(x * 3 + 5); }
while (x != y){ x = f(x * 3 + 5); }

'switch' parentheses

If selected, spaces inside parentheses in switch statements are always inserted. Otherwise, no spaces are inserted.

switch ( e.getCode() ) { }
switch (e.getCode()){ }

'try' parentheses

If selected, spaces inside parentheses in try statements are always inserted. Otherwise, no spaces are inserted.

try ( MyRes r1 = getRes(); MyRes r2 = null ) { }
try (MyRes r1 = getRes(); MyRes r2 = null) { }

'catch' parentheses

If selected, spaces inside parentheses in catch constructs are always inserted. Otherwise, no spaces are inserted.

try { get("x"); } catch ( Exception e ) { }
try{ get("x"); } catch (Exception e) { }

'synchronized' parentheses

If selected, spaces inside parentheses in synchronized statements are always inserted. Otherwise, no spaces are inserted.

synchronized ( this ) { switch ( e.getCode() ) { }
synchronized (this) { switch ( e.getCode() ) { }

Type cast parentheses

If selected, spaces inside type cast parentheses are always inserted. Otherwise, no spaces are inserted.

int[] arr = ( int[] )g(y);
int[] arr = (int[])g(y);

Annotation parentheses

If selected, spaces inside annotation parentheses are always inserted. Otherwise, no spaces are inserted.

@SuppressWarnings( {"ALL"} )
@SuppressWarnings({"ALL"})

Angle brackets

If selected, spaces inside angle brackets are always inserted. Otherwise, no spaces are inserted.

class Bar{ static < U, T > U mess(T t){ return null; } }
class Bar{ static <U, T> U mess(T t){ return null; } }

Record header

If selected, spaces inside record headers are always inserted. Otherwise, no spaces are inserted.

record Rec( String s, int i ){ }
record Rec(String s, int i){ }

Deconstruction list

If selected, spaces inside deconstruction lists are always inserted. Otherwise, no spaces are inserted.

switch ( o ) { case Rec( String s, int i ) r -> { } }
switch ( o ) { case Rec(String s, int i) r -> { } }

Inside block braces when body is present

If selected, spaces inside deconstruction lists are always inserted. Otherwise, no spaces are inserted.

if (true) { System.out.println( "Condition is true" ); }
if (true){ System.out.println( "Condition is true" ); }

In ternary operator (?:)

Item

Description

Before '?'

After '?'

Before ':'

After ':'

Between '?' and ':'

Select the checkboxes in this section to have spaces automatically inserted around ?, around :, and between ? and : in ternary operators.

For example, if Before '?' and After ':' are selected, IntelliJ IDEA automatically inserts spaces before ? and after : in ternary conditional expressions. Otherwise, no spaces are inserted.

x=y>=0 ?arr[y]: -1;
x=y>=0?arr[y]:-1;

Type arguments

Item

Description

After comma

If selected, spaces are inserted after commas in type arguments with multiple types. Otherwise, no spaces are inserted.

Bar.<String, Integer>mess(null);
Bar.<String,Integer>mess(null);

Before opening angle bracket

If selected, spaces are inserted before opening angle brackets in type arguments. Otherwise, no spaces are inserted.

Bar. <String,Integer>mess(null);
Bar.<String,Integer>mess(null);

After closing angle bracket

If selected, spaces are inserted after closing angle brackets in type arguments. Otherwise, no spaces are inserted.

Bar.<String,Integer>mess(null);
Bar.<String,Integer> mess(null);

Other

Item

Description

Before comma

If selected, spaces are automatically inserted before commas in parameter lists, argument lists, array declarations, and so on. Otherwise, no spaces are inserted.

public void foo(int x ,int y){ }
public void foo(int x,int y){ }

After comma

If selected, spaces are automatically inserted after commas in parameter lists, argument lists, array declarations, and so on. Otherwise, no spaces are inserted.

public void foo(int x,int y){ }
public void foo(int x, int y){ }

Before 'for' semicolon

If selected, spaces are automatically inserted before semicolons in for loops. Otherwise, no spaces are inserted.

for(int i=0 ;i<x ;i++){ y+=(y^0x123)<<2; }
for(int i=0;i<x;i++){ y+=(y^0x123)<<2; }

After 'for' semicolon

If selected, spaces are automatically inserted after semicolons in for loops. Otherwise, no spaces are inserted.

for(int i=0; i<x; i++){ y+=(y^0x123)<<2; }
for(int i=0;i<x;i++){ y+=(y^0x123)<<2; }

After type cast

If selected, a space is automatically inserted after the closing parenthesis of a cast. Otherwise, no space is inserted and the casted variable sticks to the cast.

int[] arr=(int[]) g(y);
int[] arr=(int[])g(y);

Around '=' in annotation value pair

If selected, spaces are automatically inserted around the = operator in annotation value pairs. Otherwise, no spaces are inserted.

@Annotation(param1 = "value1", param2 = "value2")
@Annotation(param1="value1", param2="value2")

Before colon in foreach

If selected, a space is automatically inserted before a colon in foreach loops. Otherwise, no space is inserted.

for(int a : X){ System.out.print(a); }
for(int a: X){ System.out.print(a); }

Inside one line enum braces

If selected, spaces are automatically inserted inside the braces of one-line enums around the list of constants. Otherwise, no spaces are inserted.

public enum Day{ MONDAY,TUESDAY,WEDNESDAY }
public enum Day{MONDAY,TUESDAY,WEDNESDAY}

Type parameters

Item

Description

Before opening angle bracket

If selected, a space is automatically inserted before an opening angle bracket of a type parameter. Otherwise, no space is inserted.

public class Foo <T extends Bar&Abba,U>{
public class Foo<T extends Bar&Abba,U>{

Around type bounds

If selected, spaces are automatically inserted around type bounds of a type parameter. Otherwise, no space is inserted.

public class Foo <T extends Bar&Abba,U>{
public class Foo<T extends Bar&Abba,U>{

Wrapping and Braces

In this tab, customize the code style options, which IntelliJ IDEA will apply on reformatting the source code. The left-hand pane contains the list of exceptions (Keep when reformatting), and placement and alignment options for the various code constructs (lists, statements, operations, annotations, and so on). The right-hand pane shows the preview.

Hard wrap at

Use the Hard wrap at field to specify a margin space required on the right side of an element. If you select the Default option, then a value of the right margin from the global settings is used.

Wrap on typing

Use the Wrap on typing settings to specify how the edited text is fitted in the specified Hard wrap at:

  • Default: in this case IntelliJ IDEA uses the Wrap on typing option that is specified in the global settings.

  • Yes: in this case IntelliJ IDEA uses the value specified in the Right Margin field.

  • No: in this case this option is switched off and a line can exceed the value specified in the right margin.

Visual guides

Use the Visual guides field to specify multiple right margins. You can leave a default value or enter the number of spaces for your margin. If you want to specify several margins, enter numbers separated by comma.

Keep when reformatting

Use the checkboxes to configure exceptions that IntelliJ IDEA will make when reformatting the source code. For example, by default, the Line breaks checkbox is selected. If your code contains lines that are shorter than a standard convention, you can convert them by disabling the Line breaks checkbox before you reformat the source code.

Wrapping options

The wrapping style applies to the various code constructs, specified in the left-hand pane (for example, method call arguments, method declaration parameters, or assignment statements).

Item

Description

Wrapping style

From this list, select the desired wrapping style:

  • Do not wrap: when this option is selected, no special wrapping style is applied.

    With this option selected, the nested alignment and braces settings are ignored.

  • Wrap if long: select this option to have lines going beyond the right margin wrapped with proper indentation.

  • Wrap always: select this option to have all elements in lists wrapped, so that there is one element per line with proper indentation.

  • Chop down if long: select this option to have elements in lists that go beyond the right margin wrapped, so that there is one element per line with proper indentation.

Alignment options

Item

Description

Align when multiline

If this checkbox is selected, a code construct starts at the same column on each next line. Otherwise, the position of a code construct is determined by the current indentation level.

<character(s)> on next line

Select this checkbox to have the specified character or characters moved to the next line when the lines are wrapped.

'else' on new line

Use this checkbox to have the corresponding statements or characters moved to the next line.

New line after <character>

Select this checkbox to have the code after the specified character moved to a new line.

Special 'else if' treatment

If this checkbox is selected, else if statements are located in the same line.

Otherwise, else if statements are moved to the next line to the corresponding indent level.

Indent 'case' branches

If this checkbox is selected, the case statement is located at the corresponding indent level. Otherwise, case statement is placed at the same indent level with switch.

Braces placement options

Item

Description

Braces placement style

Use this list to specify the position of the opening brace in class declarations, method declarations, and other types of declarations. The available options are:

  • End of line: select this option to have the opening brace placed at the declaration line end.

  • Next line if wrapped: select this option to have the opening brace placed at the beginning of the line after the multiline declaration line.

  • Next line: select this option to have the opening brace placed at the beginning of the line after the declaration line.

  • Next line shifted: select this option to have the opening brace placed at the line after the declaration line being shifted to the corresponding indent level.

  • Next line, each shifted: select this option to have the opening brace placed at the line after the declaration line being shifted to the corresponding indent level, and have the next line shifted to the next indent level as well.

Force braces

From this list, choose the braces introduction method for if, for, while, and do () while statements. The available options are:

  • Do not force: select this option to suppress introducing braces automatically.

  • When multiline: select this option to have braces introduced automatically if a statement occupies more than one line. Note that IntelliJ IDEA analyzes the number of lines in the entire statement but not only its condition.

    IntelliJ IDEA will insert braces automatically:

  • Always: select this checkbox to have braces always introduced automatically.

Chained method calls

Use the following options to format chained method calls and make them easier to read. Note that builder method calls are always wrapped regardless of the settings for chained calls.

Item

Description

Wrap first call

Allow wrapping the first method call in chained methods.

Align when multiline

Align several method calls.

Builder methods

Specify comma-separated names (identifiers) of methods that you want to be treated as builder methods.

For example: withTitle,withYear,addAuthor,withName,withLastName,end,build

Keep builder methods indents

Keep additional indents that you insert manually intact as you reformat code.

Blank lines

Use this tab to define where and how many blank lines you want IntelliJ IDEA to retain and insert in your code after reformatting. For each type of location, specify the number of blank lines to be inserted. The results are displayed in the preview pane.

Item

Description

Keep maximum blank lines

In this area, specify the number of blank lines to keep after reformatting in the specified locations.

Minimum blank lines

In this area, specify the minimum number of blank lines to be present in the specified locations.

JavaDoc

Item

Description

Alignment

Define the way Javadoc comments should be aligned.

  • Align parameter descriptions: align parameter descriptions against the longest parameter name. Otherwise, the description is separated from the corresponding parameter name by a single space.

  • Align thrown exception descriptions: align thrown exception descriptions against the longest exception name. Otherwise, the description is separated from the exception name by a single space.

Blank lines

Define where blank lines should be inserted in Javadoc comments.

  • After description: automatically insert a blank line after the description section of a Javadoc comment.

  • After parameter descriptions: automatically insert a blank line after the group of @param tags.

  • After return tag :automatically insert a blank line after the @return tag.

Invalid tags

In this area, define whether invalid tags should be preserved or not.

  • Keep invalid tags: preserve the @invalidTag.

  • Keep empty @param tags: preserve the @param tags without the description.

  • Keep empty @return tags: preserve the @return tags without the description.

  • Keep empty @throws tags: preserve the @throws tags without the description.

Other

In this area, specify additional formatting options for Javadoc comments.

  • Enable leading asterisks: start each line of a Javadoc comment with an asterisk.

  • Use @throws rather than @exception: use the @throws tag.

  • Wrap at right margin: wrap the text that exceeds the right margin to the next line.

  • Generate "<p>" on empty lines: automatically insert the </p> tag on an empty line.

  • Keep empty lines: select this checkbox to have manually added empty lines preserved.

  • Do not wrap one line comments: keep short comments on one line with the opening and closing tags.

  • Preserve line feeds: if this checkbox is not selected (by default), line feeds are not preserved on reformatting. This is convenient when comments should be formatted within the boundaries of a paragraph, to occupy minimum space.

    If this checkbox is selected, line feeds will be preserved.

  • Parameter descriptions on new line: place the description of a Javadoc parameter (if any) to a new line. It uses the indent based on the continuation indent value.

  • Indent continuation lines: indent subsequent lines in multiline comments.

Arrangement

This tab lets you define a set of rules that rearranges your code according to your preferences.

Item

Description

Grouping Rules

Use this area to set the grouping rules.

  • Keep getters and setters together

    Select this checkbox to keep getter and setter methods together. By default, this checkbox is selected.

  • Keep overridden methods together

    Select this checkbox to group the overridden methods together by class and interface. In order list, select keep order or order by name options.

  • Keep dependent methods together

    Select this checkbox to group the dependent methods together. In the order list, select depth-first order or breadth-first order options. The former will arrange the methods according to the nesting hierarchy; the latter will group together the sibling methods from the same nesting level.

    class foo { public function parent() { $this->child1(); $this->child2(); } private function child1() { $this->nested1(); } private function nested1() { $this->nested2(); } private function nested2() { } private function child2() { } }
    class foo { public function parent() { $this->child1(); $this->child2(); } private function child1() { $this->nested1(); } private function child2() { } private function nested1() { $this->nested2(); } private function nested2() { } }

Matching rules

Use this area to define elements order as a list of rules, where every rule has a set of matches such as modifier or type.

  • the Add button: use this button to add a rule. The empty rule area opens.

  • the Add Section Rule button: use this button to add a section rule. The section rule lets you move methods or variables into sections that you have defined.

    For example, you can create the following section rule:

    A matching rule

    After the arrangement, methods in the class will be rearranged as specified in the created section rule and will be surrounded by comments:

    //methods start public void test() {} private int a() { return 1; } static void r() {} //methods end
  • the Remove button: use this button to remove the rule from the list.

  • the Edit button: use this button to edit an existing rule. To see this button, navigate to the rule that you want to edit and click the button. In popup that opens, modify the rule fields.

  • the Move up button the Move down button: use these buttons to move the selected rule up or down.

  • Configure matching rules: use this button to configure an alias for the matching rule. In this case, when you create an arrangement rule, you can define a custom rule (alias) that includes a sequence of different rules and apply the alias to your current rule.

Empty rule

Use this area to create a new matching rule or edit an existing one. You can select from the following filters:

  • Type: use this filter to choose classes or methods for your rule.

    Note that clicking a type keyword twice negates the condition.

  • Modifier: use this filter to select the types of modifiers for the rule.

    Note that clicking a modifier keyword twice negates the condition.

  • Name: use this field to specify entry names in the rule. This filter matches only entry names, such as field names, method names, class names, and so on. The filter supports regular expressions and uses a standard syntax. The match is performed against the entire name.

  • Order: use this list to select the sorting order for the rule. This option is useful when more than one element uses the same matching rule. In this case, selecting Keep order will keep the same order as was set before the rearrangement and selecting Order by Name will sort the elements with the same matching rule by their names.

  • Aliases: this option displays aliases that were defined in the Rules Alias Definition dialog. You can remove the ones you do not need.

the Sort Alphabetically button

This icon appears when you select Order by Name from the Order list. The icon indicates that the items in this rule are sorted alphabetically.

Imports

Use this tab to configure how IntelliJ IDEA should add and organize import statements in your files. IntelliJ IDEA uses these settings when it adds an import statement automatically, when you optimize imports, and when you reformat code.

General

Use these settings to configure how IntelliJ IDEA should handle imports from other packages.

Item

Description

Use single class import

When you use a class from another package, import only the class instead of its whole package.

import java.time.*;
import java.time.Duration; import java.time.LocalDate; import java.time.LocalTime;

Use fully qualified class names

When you use a class from another package, insert the fully qualified class name inline instead of adding an import statement.

import java.time.LocalDate; LocalDate date = LocalDate.now();
java.time.LocalDate date = java.time.LocalDate.now();

Insert imports for inner classes

When you use an inner class, import the inner class instead of its outer class and refer to it by its simple name.

import com.shop.Order; Order.Item item;
import com.shop.Order.Item; Item item;

You can keep the outer class name for specific inner classes by adding their simple names to the Exclude inner classes by short name list.

Do not separate module imports into single or package imports

When you optimize imports, keep module imports instead of replacing them with single-type or wildcard package imports.

import java.time.LocalDate; import java.util.List;
import module java.base;

Delete unused module imports

When you optimize imports, delete module imports that are not used by your code.

Use fully qualified class names in JavaDoc

When you refer to a class from another package in a Javadoc comment, format the class name according to the selected option:

  • Always: use its fully qualified name and do not add an import statement.

    /** * Returns the {@link java.time.LocalDate} of the order. */
  • Never, use short name and add import: use its simple name and add an import statement.

    import java.time.LocalDate; /** * Returns the {@link LocalDate} of the order. */
  • If not already imported: use its simple name if the class is already imported; otherwise, use its fully qualified name.

    import java.time.LocalDate; /** * Returns the {@link LocalDate} and * {@link java.time.Duration} of the order. */

Class count to use import with '*'

Specify the limit for single-type imports from the same package. When a file reaches this limit, the IDE replaces these imports with a wildcard package import.

import java.time.Duration; import java.time.Instant; import java.time.LocalDate; import java.time.LocalTime;
import java.time.*;

Names count to use static import with '*'

Specify the limit for static imports from the same class. When a file reaches this limit, the IDE replaces these imports with a wildcard import of all static members.

import static java.lang.Math.abs; import static java.lang.Math.max;
import static java.lang.Math.*;

Packages to Use Import with '*'

Use this table to specify packages and classes for which the IDE should always use a wildcard import (ending with *). You can use it in two ways:

  • To import a whole package whenever you use one of its classes (instead of only that class), add the package name. To apply this rule to its subpackages too, select With Subpackages. Here is an example where java.time is added to the table:

    import java.time.*; import java.time.format.DateTimeFormatter;
    import java.time.*; import java.time.format.*;
  • To import all static members of a class whenever you use one of its static members (instead of only that member), add the class name and select Static. Here is an example where java.util.Collections is added to the table:

    import static java.util.Collections.emptyList;
    import static java.util.Collections.*;

To add and remove rows, use the icons in the table toolbar.

Import layout

Use these settings to configure the order, grouping, and line spacing of import statements.

Item

Description

Place on-demand import before single-class imports from the same package

When a file includes a wildcard package import and single-type imports from the same package, place the wildcard import first instead of last.

import java.awt.*; import java.util.List; import java.util.*;
import java.awt.*; import java.util.*; import java.util.List;

Keep blank lines between imports

When you optimize imports or reformat code, keep the existing blank lines between import statements instead of using only the blank lines from the Import layout table.

import javax.sql.DataSource; import java.time.LocalDate; import java.util.List;
import javax.sql.DataSource; import java.time.LocalDate; import java.util.List;

Layout static imports separately

When you optimize imports, place static imports in their own groups instead of sorting them with other imports from the same package.

import java.time.Duration; import static java.time.Duration.ofSeconds; import java.time.LocalDate;
import java.time.Duration; import java.time.LocalDate; import static java.time.Duration.ofSeconds;

Import layout

Configure the order of import statements in your files and organize them into groups.

The layout is defined at the package level. By default, the position of a package applies to both its wildcard imports and single-type imports. You can change this scope with the following options:

  • Static: use this position only for the static imports from this package. Here is an example where java.time is added to the top of the default layout:

    import java.time.LocalDate; import java.sql.Connection; import static java.time.temporal.ChronoUnit.DAYS;
    import static java.time.temporal.ChronoUnit.DAYS; import java.sql.Connection; import java.time.LocalDate;
  • With Subpackages: use this position for imports from both this package and its subpackages. Here is an example where java.time is added to the top of the default layout:

    import java.time.LocalDate; import java.sql.Connection; import java.time.format.DateTimeFormatter;
    import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.sql.Connection;

To add packages and blank lines, remove them, or change their order, use the icons in the table toolbar.

Code Generation

Item

Description

Naming

  • Prefer longer names: Highlight the longest name in the lookup list for code completion. If disabled, highlight the shortest name.

  • Name prefix and Name suffix: Specify the prefixes and suffixes for generating suggestions for naming new symbols using the IntelliJ IDEA code generation features. For blank fields, the default name suggestions without prefixes or suffixes are used. When you add a prefix value, IntelliJ IDEA automatically converts the first letter of the suggested base name to the upper case.

    For example, if the prefix for a static field is defined as s and the type of the field is Counter, then the suggested static field name will be sCounter.

Default Visibility

Select the default access level for generated fields and methods.

You can either specify it explicitly, or select Escalate to automatically raise it to a necessary level.

Variable declaration

Specify whether you want to generate local variables and parameters with the final modifier by default.

Comment Code

Use this area to configure code style for generated comments (line Ctrl+/ and block Ctrl+Shift+/):

  • Line comment at first column: start line comments (Ctrl+/) at the first column. If you disable the option, the comments will be aligned with your code.

  • Add a space at comment start: insert a space between the line comment character and the first character of the commented line.

  • Enforce on reformat: insert a space between a line comment character and the first character of a commented line in existing comments when you're reformatting your code. Note that the first character has to be an alphanumeric symbol, otherwise the space won't be inserted. For example, the //&Lorem ipsum comment will be ignored by the reformatter.

    This option becomes available when Add a space at comment start is enabled.

  • Block comment at first column: start block comments (Ctrl+Shift+/) at the first column. If you disable the option, the comments will be aligned with your code.

  • Add spaces around block comments: insert a space between the block comment character and the first character of the commented text.

  • Prefer documentation line comments: use the Markdown comment style instead of the traditional style when you insert Javadoc comments with quick actions.

Override Method Signature

  • Insert @Override annotation: Insert @Override annotations when you override a method.

  • Repeat synchronized modifier: Add the synchronized keyword when you override a method that is synchronized.

  • Annotations to Copy: Specify which annotations should be copied over to the method that you override.

  • Use external annotations: Prompt to specify whether you want an annotation to be stored in the source code or externally. If disabled, annotations will be added to the source code by default.

Lambda Body

If a lambda expression calls an existing method, it is preferable to refer to the method by name using a method reference. These checkboxes affect the Lambda can be replaced with method reference inspection. If enabled, the corresponding lambda expressions will be highlighted as warnings with a relevant quick-fix. If disabled, the code will not be highlighted, but an intention to replace the lambda expression with a method reference will still be available.

  • Use Class::isInstance and Class::cast when possible

    For example, replace obj1 -> obj1 instanceof Foo with Foo.class::isInstance and obj -> (Foo)obj with Foo.class::cast.

  • Replace null-check with Objects::nonNull or Objects::isNull

    For example, replace x -> x != null with Objects::nonNull.

  • Use Integer::sum, etc. when possible

    For example, replace (a, b) -> a + b with Integer::sum.

12 November 2026