Easy learning with example program codes

java annotations overview

Dictionary meaning of Annotation

Annotation refers to a note by way of explanation or comment added to a text or diagram.

Java Annotations:

Java annotations are used to provide the meta data to our Java code. Meta data is the additional information which can be used for any class, interface, method or field. Java annotations can be used as an alternative option for XML and java marker interfaces. Java annotations were added to Java from Java 5.

Java annotations basics:

A java annotation always starts with the symbol @ and followed by the annotation name. The @symbol signals the compiler that this is an annotation.





Here @ symbol signals the compiler that this is an annotation and the Entity is the name of this annotation.

An annotation can contain zero, one or multiple elements. We have to set values for these elements.

@Entity(tableName = "USERS")

Where we can use annotations?

We can use java annotations above classes, interfaces, methods, fields and local variables. Here is an example annotation added above a class definition:

 public class Users {

Java Annotations List:

  • @Deprecated
  • @Override
  • @SuppressWarnings
  • @Target
  • @Retention
  • @Inherited
  • @Documented

Sign Up/ Sign In
Ask a Question

Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at


We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on

Copyright © 2018 CodesJava Protection Status SiteMap Reference: Java Wiki