What are annotations in Java?

Annotations are a tag (metadata) which provides info about a program.

  • Annotations in Java Start with the symbol ‘@’.
  • They are used by the compiler to detect errors.
  • Software tools to generate code.
  • They are used to show attributes of an element: e.g. @Deprecated, @Override.
  • Annotation are used to describe the purpose of an element of the framework, e.g. @Entity, @TestCase, @WebService
  • Annotations describe the behaviour of an element: @Statefull, @Transaction.


Live Demo

class Sample{
   public void display(){
      System.out.println(" ");
public class Test extends Sample {
   public void display(){
      System.out.println("Welcome to Tutorialspoint");
   public static void main(String[] args) {
      Test obj = new Test();


Welcome to Tutorialspoint

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 30-Jul-2019


Kickstart Your Career

Get certified by completing the course

Get Started