Posts

Showing posts with the label Annotations in Java

Annotations in Java

Annotations are the tags that can be inserted into a Java programs so that they can be processed by the tools. In the Java programming language, an annotation is used like a modifier, and it is placed before the annotated item, without a semicolon. The name of each annotation is preceded by an @ symbol.  For Example: @Override   public boolean equals(Object obj){  ...  }  Annotation Syntax An annotation is defined by an annotation interface:  public  @interface AnnotationName {   //element declarations    type elementName () ;    type   elementName () default value ;   . . .  }  One of the following   type can be used for annotation fields: All primitives (boolean, char, short, int, long, double) String Class Enum Array of any of above types Meta-Annotations Meta annotations are annotations that are used to annotate annotations. T...