Type Annotations: An added feature to annotations in JAVA 8

Earlier we could only use annotations in Java on declarations. With Java 8, annotations can be written on any use of a type in declarations, generics, and casts. Type annotations are not one of the highlighted features of Java 8. Annotations add more behavior to the piece of code we have written. So type annotation is just an add-on to that, in the sense, it boosts the productivity and ensures higher-quality for our code.

For example, if you want to ensure that a particular variable is never assigned to null. You would then modify your code to annotate that particular variable, indicating that it is never assigned to null. The declaration can be like this:

@NonNull String str;

When you compile the code the compiler prints a warning if it detects a defect, which allows you to modify the code if an error is found. After you correct the code to remove all warnings, this particular error will not occur when the program runs.

When we look for tools that make our...