A few times, after I code a block of code, I want to execute it only if a condition is true. For example I want to perform some operations on an object person but only if it is not null (obviously). Eclipse has a quick fix to surround this block of code with an if statement. Just select the block of code and press Crtl + 1 or choose Edit > Quick Fix. Eclipse gives you a list of options as shown above. You can choose “Surround with ‘if’ (if statement)” and the code is surrounded by an if statement. You can fill up the condition and you are done.
You can also use the above trick to get other surround statements listed above.