jsf JSF Annotations Introduction to annotations

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

Why annotations?

Generally we use annotation to facilitate the development and to make the code more clear and clean.

What are annotations?

Java 5 annotations provide standardization of metadata in a general goal. This metadata associated with Java features can be exploited in the compilation or execution.

Java was modified to allow the implementation of annotations:

  • A dedicated syntax was added in Java to allow the definition and use of annotations.
  • bytecode is enhanced to allow storage of annotations.

Where can annotations be used?

Annotations can be used with :

packages, classes, interfaces, constructors, methods, fields, parameters, variables or annotations themselves.

Categories of annotation

There are three categories of annotation:

  • Markers: These annotations do not have an attribute

For example @Deprecated, @Override ...

  • Single value annotation: these annotations have only one attribute

For example @MyAnnotation ( "test")

  • Full annotations: these annotations have multiple attributes

For example @MyAnnotation (arg1 = "test 3", arg2 = "test 2", arg3 = "test3")

Like we see before you can create your own annotation



Got any jsf Question?