This annotation is commonly used to eliminate NullPointerExceptions
. @Nullable
says that this parameter might be null
. A good example of such behaviour can be found in Google Guice. In this lightweight dependency injection framework you can tell that this dependency might be null
. If you would try to pass null
without an annotation the framework would refuse to do it's job.
What is more @Nullable
might be used with @NotNull
annotation. Here you can find some tips on how to use them properly. Code inspection in IntelliJ checks the annotations and helps to debug the code.