tpuli
tpuli

Reputation: 435

Formatting if-else in eclipse

is there any way to format if-else statement in Eclipse where multiple conditions come in each line while pressing Ctrl+Shift+F? I tried to fiddle around in Preferences -> Java -> Code Style -> Formatter, but was not able to find the right option to get it working.

The format that i am trying to achieve is as follows.

if(condition1 == true
       && condition2 == true
       && condition3 == true
       && condition4 == true
       && condition5 == true) {
    return 0;
}

Any suggestions?

Upvotes: 2

Views: 2346

Answers (3)

dskfdskjgds
dskfdskjgds

Reputation: 351

Sadly you can't do what you want using Code Style -> Formatter, but yes, writing in parenthesis will work.

Upvotes: 0

csarathe
csarathe

Reputation: 430

May be your requirement adjusted in below confirguration.

Preferences -> Java -> Code Style -> Formatter -> Edit

enter image description here

Upvotes: 1

Zain Sheikh
Zain Sheikh

Reputation: 1

Strict every condition in parenthesis , it will work .

Upvotes: 0

Related Questions