Contents
The basic idea is, that sometimes you forget to start an expression with the right term. Then you can add a post completion string and IntelliJ IDEA transform the expression in the right shape. JetBrains explains the post completion in this article.
Here are some examples that I use often:
Null or Not Null?
You want to do a null check of a variable? Simply enter the name of the variable and add “.null”
![Postfix Completion in IntelliJ 2 Postfix Completion in IntelliJ - postfix null](http://praxisit.de/wp-content/uploads/postfix-null.png)
and the result is
![Postfix Completion in IntelliJ 3 Postfix Completion in IntelliJ - postfix null result 1](http://praxisit.de/wp-content/uploads/postfix-null-result-1-300x111.png)
Or if you want to make sure that a variable is not null? Enter “.nn”
![Postfix Completion in IntelliJ 4 Postfix Completion in IntelliJ - postfix nn](http://praxisit.de/wp-content/uploads/postfix-nn-1024x146.png)
and you get
![Postfix Completion in IntelliJ 5 Postfix Completion in IntelliJ - postfix nn result](http://praxisit.de/wp-content/uploads/postfix-nn-result.png)
For loop
You don’t want to enter a for loop all by yourself? Just write the name of the collection and add “.for”
![Postfix Completion in IntelliJ 6 Postfix Completion in IntelliJ - postfix for](http://praxisit.de/wp-content/uploads/postfix-for.png)
then you’ll get
![Postfix Completion in IntelliJ 7 Postfix Completion in IntelliJ - postfix for result](http://praxisit.de/wp-content/uploads/postfix-for-result.png)
Try
After you’ve typed a variable declaration, you remembered that this can throw an exception that you want to catch. Simply type “.try” and get the try-catch-block for free
![Postfix Completion in IntelliJ 8 Postfix Completion in IntelliJ - postfix try](http://praxisit.de/wp-content/uploads/postfix-try.png)
and the result is:
![Postfix Completion in IntelliJ 9 Postfix Completion in IntelliJ - postfix try result](http://praxisit.de/wp-content/uploads/postfix-try-result.png)
Postfix completion in other languages
Postfix completion is not only available for Java but also for JavaScript, Scala and Kotlin. Most of the commands mean the same, but there are language specific commands, like “.val” for Kotlin.
Next steps
As you can see, postfix completion is worth another look. So don’t hesitate to find the completions you like most.