Get a lot of goodies every week in your mailbox. Absolutely free. Enter your email address below.
Java 8 brought many new features like Lambda, functional interfaces and Streams but there is one feature that is not much talked about and that is "type annotations". Who's this new kid on the block? Let's take a look. What are type annotations? Java introduced a new feature called annotations in Java 5. Java had some built in like @Override and then the specifications and Frameworks created their own annotations like @Entity, @Autowired etc as well. All these were used as metadata for verification or for code generation in some cases. These annotations were only applied to the declarations - when classes, methods and fields were declared. What Java 8 brings to the table is type annotations which means these annotations can be used anywhere where the type has been used, for example while accepting an argument in the method definition, you can specify that this argument value cannot be null using a type annotation like @NotNull shown below. String myMeth...
Comments
Post a Comment