0

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?

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much, I just learned this as well from: youtube.com/watch?v=kRAeKO-5xpQ Thank you for answering my question and helping me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.