Thuy
Thuy

Reputation: 1657

Eclipse format code: force array initializer to be on same line

When I format my code in Eclipse, my array initializer goes from:

int[] array = {1, 2, 3};

to:

int[] array =     
{1, 2, 3};

Why is the {1, 2, 3}; on a new line instead of the same line as the array declaration after formatting?

How do I fix this so that the {1, 2, 3} stays on the same line as the int[] array after formatting?

Would you help me?

Upvotes: 0

Views: 625

Answers (1)

alex
alex

Reputation: 705

Go to Window > Preferences > Java > Formatter > Edit active profile > Braces and change Array initializer from "Next line" to "Same line"

Upvotes: 4

Related Questions