Annotation & their uses in Java

Photo Thanks

What is Annotation..?

  1. methods
  2. class
  3. interface
  1. @override — used to override the parent class method in sub class method
  2. @SuppressWarnings — used to suppress warnings issued by the compiler.
  3. @Deprecated — compiler prints warning because of the method is deprecated as it could be removed in the future versions. So that its better not to use such method.
  • method should not have parameters
  • should not throw any clause
  • may have default values
  • should return a class, method, enum, String like primitive data type
  1. Marker Annotation
  2. Single Value Annotation
  3. Multi-value Annotation
  4. Marker Annotation — Annotation that have no methods inside it.
  1. @Target
  2. @Retention
  3. @Inherited
  4. @Documented
  5. @Target — used to betoken to which type the annotation to be used
  • SOURCE — this refers the source code, which the annotation will not be available in compiled class.
  • CLASS — this refers to the .class file, which the annotation will not available to JVM but available for java compiler. So, it will be in the class file.
  • RUNTIME — refers runtime, which is available to bothe java compiler & jvm.




A passionate in Tech

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

DevOps Economics


Setting up Visual Studio Code (VS Code) with C++ on Ubuntu (Linux)

Client-Side — The Security Blindspot of your Website

Snowflake Qualify

Garnet Silver dishy wholesales Earring Red L-1.2in UK gift

Open source databases and GCP. Why are they worth considering?

Open source databases and GCP

Para 🎲🎲 Lost File#16

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Parathan Thiyagalingam

Parathan Thiyagalingam

A passionate in Tech

More from Medium

Exceptions in JAVA

Java Coding Standards

Java Optional

Functional Programming In Java