Jindent - Java Source Code Formatter http://www.jindent.com
 



title
5.6.1.5 If-Else Statements

title
5.6.1.5.1 Misc

Single if statement in one line

Single if statement in one line

Controls formatting of if statements which just contain a single statement instead a block body.


Format if statement in one line:

if (a < 10) callMethod(a);              


Do not format if statement in one line:

if (a < 10)                             
    callMethod(a);                      



Single else statement in one line

Single else statement in one line

Controls formatting of else part of if-else statements which just contain a single statement instead a block body.


Format else statement in one line:

if (a < 10) callMethod(a)               
else callOtherMethod(a);                


Do not format else statement in one line:

if (a < 10) callMethod(a)               
else                                    
    
callOtherMethod(a);                 


Do not format if and else statement in one line:

if (a < 10)                             
    callMethod(a)                       
else                                    
    
callOtherMethod(a);                 



Treat else and if as one else/if statement

Treat else and if as one else/if statement

Controls whether else and if statements are put together as one statement or not.


Treat else and if statements as one statement:

if (a < 10) {                           
    
System.out.println("a");            
else if (b < 10) {                    
    
System.out.println("b");            
else if (c < 10) {                    
    
System.out.println("c");            
else                                  
    
System.out.println("none");         


Do not use special else if treatment:

if (a < 10) {                           
    
System.out.println("a");            
else                                  
    if 
(b < 10) {                       
        
System.out.println("b");        
    } 
else                              
        if 
(c < 10) {                   
            
System.out.println("c");    
        } 
else                          
            
System.out.println("none");