Example

public static void main( String[] args ) {
if ( args.length > 3 ) {
System.out.println( "More than 3" ); //$NON-NLS-1$
if ( args[ 0 ].startsWith( "a" ) ) { //$NON-NLS-1$
System.out.println( "Starts with a" ); //$NON-NLS-1$
if ( args[ 1 ].endsWith( "z" ) ) { //$NON-NLS-1$
System.out.println( "Ends with z"); //$NON-NLS-1$
}
}
}
}

Solution
Invert the condition and add a return statement.
The following solution is discussed in Refactoring by Martin Fowler.
  1. Invert the condition of the outer-most if statement.
  2. Add a return statement below the if statement.
  3. Repeat these steps until there are no more deeply nested if statements.

public static void main( String[] args ) {
if ( args.length <= 3 ) {
return ;
}

System.out.println( "More than 3" ); //$NON-NLS-1$

if ( !args[ 0 ].startsWith( "a" ) ) { //$NON-NLS-1$
return ;
}

System.out.println( "Starts with a" ); //$NON-NLS-1$

if ( args[ 1 ].endsWith( "z" ) ) { //$NON-NLS-1$
System.out.println( "Ends with z" ); //$NON-NLS-1$
}

}