

{"id":13248,"date":"2018-04-12T08:52:20","date_gmt":"2018-04-12T08:52:20","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=13248"},"modified":"2026-05-20T10:54:58","modified_gmt":"2026-05-20T05:24:58","slug":"java-annotations","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/java-annotations\/","title":{"rendered":"Java Annotations &#8211; Examples &amp; Types of Annotations in Java"},"content":{"rendered":"<p>In our last tutorial, we saw Java assertions in detail. In this Java Annotations tutorial, what are Java annotations, and a list of annotations in Java Programming Language: Marker, Single Value, and Full Java Annotations. Moreover, we will discuss Predefined\/ Standard Annotations or built-in annotations in Java. At last, we discuss some Java annotation examples.<\/p>\n<p>So, let&#8217;s start with the Java Annotations Tutorial.<\/p>\n<h3>What are Java Annotations?<\/h3>\n<p>Java annotations are used to provide extra or supplementary information about the program. Therefore, Annotations in Java are utilized to give supplementary data about a program.<\/p>\n<ul>\n<li>Java Annotations begin with &#8216;@&#8217;.<\/li>\n<li>They don&#8217;t change the activity of an ordered program.<\/li>\n<li>It help to relate metadata (data) to the program components, i.e., case factors, <strong>constructors<\/strong>, strategies, <strong>classes<\/strong>, and so on.<\/li>\n<li>Annotations in Java are not unadulterated remarks, as they can change the way a program is dealt with by the compiler. See the code, for instance.<\/li>\n<\/ul>\n<p><strong>Java Annotation Example \u2013<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">class Base\r\n{\r\n\u00a0\u00a0\u00a0\u00a0 public void display()\r\n\u00a0\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(\"Base display()\");\r\n\u00a0\u00a0\u00a0\u00a0 }\r\n}\r\nclass Derived extends Base\r\n{\r\n\u00a0\u00a0\u00a0\u00a0 @Override\r\n\u00a0\u00a0\u00a0\u00a0 public void display(int x)\r\n\u00a0\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(\"Derived display(int )\");\r\n\u00a0\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0\u00a0 public static void main(String args[])\r\n\u00a0\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Derived obj = new Derived();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 obj.display();\r\n\u00a0\u00a0\u00a0\u00a0 }\r\n}<\/pre>\n<h3>Categories of Java Annotations<\/h3>\n<p>There are 3 types of Annotations in Java.<\/p>\n<div id=\"attachment_13271\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Categories-of-Annotations-01.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-13271\" class=\"wp-image-13271 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Categories-of-Annotations-01.jpg\" alt=\"Java Annotations\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Categories-of-Annotations-01.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Categories-of-Annotations-01-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Categories-of-Annotations-01-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Categories-of-Annotations-01-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Categories-of-Annotations-01-1024x536.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-13271\" class=\"wp-caption-text\">Types of Annotations in Java<\/p><\/div>\n<h4>1. Marker Java Annotations<\/h4>\n<p>The main design is to mark an annotation in Java. However, these Java annotations contain no individual and don&#8217;t comprise any information. Along these lines, its quality as a comment is adequate. Since the marker interface contains no individuals, just deciding if it is available or missing is adequate. @Override is a case of Marker Annotation.<\/p>\n<p><strong>Example: &#8211;<\/strong> @TestAnnotation()<\/p>\n<h4>2. Single Value Java Annotations<\/h4>\n<p>These annotations contain just a single part and permit a shorthand type of determining the estimation of the part. Thus, we just need to indicate the incentive for that part when the comment is connected, and we don&#8217;t have to determine the name of the part. However, to utilize this shorthand, the name of the part should be valued.<\/p>\n<h4>3.\u00a0 Full Java Annotations<\/h4>\n<p>They contain multiple values, pairs, data members, etc.<\/p>\n<p><strong>Example:-<\/strong> @TestAnnotation(owner=\u201dShadow\u201d, value=\u201dClass Flair\u201d)<\/p>\n<h3>Predefined\/ Standard Java Annotations<\/h3>\n<p>There are seven built-in annotations in Java.<\/p>\n<p>i. The four imported from java.lang.annotation<\/p>\n<p>@Retention, @Documented, @Target, and @Inherited<\/p>\n<p>ii. The three in java.lang<\/p>\n<p>@Deprecated, @Override, and @SuppressWarnings<\/p>\n<div id=\"attachment_13272\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Predefined-Standard-Annotations-01.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-13272\" class=\"wp-image-13272 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Predefined-Standard-Annotations-01.jpg\" alt=\"Java Annotations\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Predefined-Standard-Annotations-01.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Predefined-Standard-Annotations-01-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Predefined-Standard-Annotations-01-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Predefined-Standard-Annotations-01-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Predefined-Standard-Annotations-01-1024x536.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-13272\" class=\"wp-caption-text\">Predefined\/ Standard Java Annotations<\/p><\/div>\n<h4>1. @Deprecated Annotation<\/h4>\n<ul>\n<li>@ Deprecated Annotation is\u00a0used to indicate that a declaration has become old and has been replaced by a newer one, thus it is a marker annotation<\/li>\n<li>The Javadoc @deprecated tag ought to be utilized when a component has been deployed.<\/li>\n<li>A @deprecated tag is for documentation, and the @Deprecated annotation is for runtime reflection.<\/li>\n<li>A @deprecated tag has a higher need than the @Deprecated annotation when both areas are utilized.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\">public class DeprecatedTest\r\n{\r\n\u00a0\u00a0\u00a0 @Deprecated\r\n\u00a0\u00a0\u00a0 public void Display()\r\n\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(\"Deprecatedtest display()\");\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0 public static void main(String args[])\r\n\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 DeprecatedTest d1 = new DeprecatedTest();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d1.Display();\r\n\u00a0\u00a0\u00a0 }\r\n}<\/pre>\n<h4>2. @Override Annotation<\/h4>\n<p>@Override Annotations are a marker annotation that can be utilized only on strategies. A technique clarified with @Override must supersede a strategy from a superclass. If it doesn&#8217;t, an order time error will come about. Hence, it is utilized to guarantee that a superclass technique is really superseded, and not just overloaded.<\/p>\n<p>Therefore, this annotation informs the compiler about whether the method that is overridden follows the correct attributes or not. Thus, we can conclude that Annotations act as a type check for the program and alert the compiler.<\/p>\n<pre class=\"EnlighterJSRAW\">class Base\r\n{\r\n\u00a0\u00a0\u00a0\u00a0 public void Display()\r\n\u00a0\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(\"Base display()\");\r\n\u00a0\u00a0\u00a0\u00a0 }\u00a0\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0 public static void main(String args[])\r\n\u00a0\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Base t1 = new Derived();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 t1.Display();\r\n\u00a0\u00a0\u00a0\u00a0 }\u00a0\u00a0\u00a0\u00a0\r\n}\r\nclass Derived extends Base\r\n{\r\n\u00a0\u00a0\u00a0\u00a0 @Override\r\n\u00a0\u00a0\u00a0\u00a0 public void Display()\r\n\u00a0\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(\"Derived display()\");\r\n\u00a0\u00a0\u00a0\u00a0 }\r\n}<\/pre>\n<p><strong>Output \u2013<\/strong><br \/>\n<strong>Derived displays<\/strong><\/p>\n<h4>3. @SuppressWarnings Annotation<\/h4>\n<p>These Annotations are used to educate the compiler to suppress indicated compiler notices. Therefore, the warnings are indicated by the name in a string structure. This sort of annotation can connect to a statement.<\/p>\n<p>Java warnings notices under two classifications. They are depreciated and unchecked. Hence, any unchecked cautioning is created when an inheritance code interfaces with a code that utilizes generics.<\/p>\n<pre class=\"EnlighterJSRAW\">class DeprecatedTest\r\n {\r\n\u00a0\u00a0\u00a0 @Deprecated\r\n\u00a0\u00a0\u00a0 public void Display()\r\n\u00a0 \u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(\"Deprecatedtest display()\");\r\n\u00a0\u00a0 \u00a0 }\r\n }\r\npublic class SuppressWarningTest\r\n {\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0 @SuppressWarnings({\"checked\", \"deprecation\"})\r\n\u00a0\u00a0 \u00a0 public static void main(String args[])\r\n\u00a0\u00a0\u00a0  {\r\n\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 DeprecatedTest d1 = new DeprecatedTest();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0 d1.Display();\r\n\u00a0\u00a0\u00a0   }\r\n  }<\/pre>\n<p><strong>Output-<\/strong><br \/>\n<strong>Deprecatedtest display()<\/strong><\/p>\n<h4>4. @Documented Annotations<\/h4>\n<p>It is a marker interface that tells an apparatus that an explanation is to archive. Therefore, Annotations in Java are excluded by Javadoc remarks. As a result, Utilization of the @Documented comment in the code empowers devices like Javadoc to process it and incorporate the explanation composed data in the produced archive.<\/p>\n<h4>5. @Target Annotations<\/h4>\n<p>It is intended to be utilized just as an explanation for another annotation. @Target takes one argument, which must be consistent with the ElementType count. However, this annotation determines the kind of assertions to which Java annotations can connect. The constants appear alongside the sort of affirmation to which they relate.<\/p>\n<p><strong>Table 1 &#8211; @ Target Java Annotations<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"312\"><strong>Target Constant<\/strong><\/td>\n<td width=\"312\"><strong>Java Annotations Can be Applied To<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"312\">ANNOTATION_TYPE<\/td>\n<td width=\"312\">Another annotation<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">CONSTRUCTOR<\/td>\n<td width=\"312\">Constructor<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">FIELD<\/td>\n<td width=\"312\">Field<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">LOCAL_VARIABLE<\/td>\n<td width=\"312\">Local variable<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">METHOD<\/td>\n<td width=\"312\">Method<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">PACKAGE<\/td>\n<td width=\"312\">Package<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">PARAMETER<\/td>\n<td width=\"312\">Parameter<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">TYPE<\/td>\n<td width=\"312\">Class, Interface, or enumeration<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Hence, we can indicate at least one of these qualities in a @Targetannotation. To determine different esteem, we should indicate them inside the props delimited list. For instance, to indicate that an annotation applies just to fields and neighborhood factors, you can utilize this @Target comment: @Target({ElementType.FIELD, ElementType.LOCAL_VARIABLE}) @Retention Annotation. Therefore, it figures out where and to what extent the comment is retained. The 3 esteems that the @Retention explanation can have:<\/p>\n<ul>\n<li><strong>SOURCE:<\/strong>\u00a0Annotations will hold at the source level and will be disregarded by the compiler.<\/li>\n<li><strong>CLASS:<\/strong> Annotations will be held at order time and overlooked by the JVM.<\/li>\n<li><strong>RUNTIME:<\/strong> These will hold at runtime.<\/li>\n<\/ul>\n<h4>6. @Inherited Annotations<\/h4>\n<p>@Inherited Java annotations are marker annotations that can utilize just on annotation affirmation. Therefore, it influences just the explanations that will be utilized for class presentations. @Inherited comments are acquired by a subclass from a superclass. In this way, when a demand for a particular comment is made to the subclass, if that comment is absent in the subclass, at that point, its superclass checks. Moreover, if that comment is available in the superclass, and if it is clarified with @Inherited, at that point, that comment will return.<\/p>\n<h4>7. User-defined\/ Custom Annotations<\/h4>\n<p>Client-characterized Java explanations can be utilized to clarify program components, i.e., factors, constructors, techniques, and so forth. However, these explanations can connect just before the statement of a component (constructor, strategy, classes, and so forth).<br \/>\n<strong>Syntax of user-defined\/ custom annotations in Java \u2013<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">[Access Specifier] @interface&lt;AnnotationName&gt;\r\n{\r\nDataType &lt;Method Name&gt;() [default value];\r\n}<\/pre>\n<ul>\n<li>AnnotationName is an identifier.<\/li>\n<li>Parameter ought not to relate to strategy assertions, and the toss provision ought not be used with technique revelation.<\/li>\n<li>Parameters won&#8217;t have an invalid estimate, yet can have a default value.<\/li>\n<li>Default esteem is discretionary.<\/li>\n<li>Return kind of strategy ought to be either crude, enum, string, class name, or exhibit of crude, enum, string, or class name write.<\/li>\n<\/ul>\n<p><strong>Example of user-defined\/ custom annotations in Java\u2013<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">import java.lang.annotation.Documented;\r\nimport java.lang.annotation.Retention;\r\nimport java.lang.annotation.RetentionPolicy;\r\n @Documented\r\n@Retention(RetentionPolicy.RUNTIME)\r\n@ interface TestAnnotation\r\n{\r\n    String Developer() default \"Rahul\";\r\n    String Expirydate();\r\n}\r\npublic class Test\r\n{\r\n    @TestAnnotation(Developer=\"data\", Expirydate=\"01-10-2020\")\r\n    void fun1()\r\n    {\r\n        System.out.println(\"Test method 1\");\r\n    }\r\n    @TestAnnotation(Developer=\"fair\", Expirydate=\"01-10-2020\")\r\n    void fun2()\r\n    {\r\n        System.out.println(\"Test method 2\");\r\n    }\r\n    public static void main(String args[])\r\n    {\r\n        System.out.println(\"Hello\");\r\n    }\r\n}<\/pre>\n<p><strong>Output \u2013<\/strong><br \/>\n<strong>Hello<\/strong><\/p>\n<p>Hence, This was all about Java Annotations Tutorial. Hope you like our explanation.<\/p>\n<h3>Real-World Applications of Annotations in Java<\/h3>\n<p>Annotations play a crucial role in various Java frameworks and libraries. Here are some examples:<\/p>\n<p><strong>1. Spring Framework:<\/strong> Spring extensively utilizes annotations for configuration purposes. Thus, Annotations like @Autowired and @Controller simplify dependency injection and component management.<\/p>\n<p><strong>2. Hibernate:<\/strong> Hibernate leverages annotations for object-relational mapping. As a result, the Java annotations connect the objects to the relational database. This maps the classes and objects to the database. Therefore, Annotations like @Entity and @Column map Java classes and their properties to database tables and columns.<\/p>\n<p><strong>3. JUnit:<\/strong> JUnit employs annotations like @Test and @BeforeClass to identify test methods and manage test execution lifecycles.<\/p>\n<h3>Conclusion<\/h3>\n<p>Hence, in this Java tutorial, we learned about Java annotations and types of annotations in Java: Marker, Single Value, and Full Java Annotations. In addition, we will discuss Predefined\/ Standard Java Annotations or built-in annotations in Java. In conclusion, we discuss some Java annotation examples. Furthermore, if you have any queries, feel free to ask in the comments section.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In our last tutorial, we saw Java assertions in detail. In this Java Annotations tutorial, what are Java annotations, and a list of annotations in Java Programming Language: Marker, Single Value, and Full Java&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":13270,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[115,116,119,120,123,124,2218,4964,7373,8572,15014,15231],"class_list":["post-13248","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-deprecated-annotation","tag-documented-annotations","tag-inherited-annotations","tag-override-annotation","tag-suppresswarnings-annotation","tag-target-annotations","tag-built-in-annotations-in-java","tag-full-java-annotations","tag-java-annotations-tutorial","tag-marker-java-annotations","tag-types-of-annotation-in-java","tag-user-defined-annotations"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Java Annotations - Examples &amp; Types of Annotations in Java - DataFlair<\/title>\n<meta name=\"description\" content=\"Java Annotations tutorial-types of annotations in Java, Java Annotation example, built-in annotation in java and real world applications.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/java-annotations\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Annotations - Examples &amp; Types of Annotations in Java - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Java Annotations tutorial-types of annotations in Java, Java Annotation example, built-in annotation in java and real world applications.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/java-annotations\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-12T08:52:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-05-20T05:24:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Java-Annotation-01.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java Annotations - Examples &amp; Types of Annotations in Java - DataFlair","description":"Java Annotations tutorial-types of annotations in Java, Java Annotation example, built-in annotation in java and real world applications.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/java-annotations\/","og_locale":"en_US","og_type":"article","og_title":"Java Annotations - Examples &amp; Types of Annotations in Java - DataFlair","og_description":"Java Annotations tutorial-types of annotations in Java, Java Annotation example, built-in annotation in java and real world applications.","og_url":"https:\/\/data-flair.training\/blogs\/java-annotations\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-04-12T08:52:20+00:00","article_modified_time":"2026-05-20T05:24:58+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Java-Annotation-01.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/java-annotations\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/java-annotations\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Java Annotations &#8211; Examples &amp; Types of Annotations in Java","datePublished":"2018-04-12T08:52:20+00:00","dateModified":"2026-05-20T05:24:58+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/java-annotations\/"},"wordCount":1253,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/java-annotations\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Java-Annotation-01.jpg","keywords":["@Deprecated Annotation","@Documented Annotations","@Inherited Annotations","@Override Annotation","@SuppressWarnings Annotation","@Target Annotations","built-in annotations in Java","Full Java Annotations","Java Annotations tutorial","Marker Java Annotations","Types of Annotation in Java","User-defined Annotations"],"articleSection":["Java Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/java-annotations\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/java-annotations\/","url":"https:\/\/data-flair.training\/blogs\/java-annotations\/","name":"Java Annotations - Examples &amp; Types of Annotations in Java - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/java-annotations\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/java-annotations\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Java-Annotation-01.jpg","datePublished":"2018-04-12T08:52:20+00:00","dateModified":"2026-05-20T05:24:58+00:00","description":"Java Annotations tutorial-types of annotations in Java, Java Annotation example, built-in annotation in java and real world applications.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/java-annotations\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/java-annotations\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/java-annotations\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Java-Annotation-01.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Java-Annotation-01.jpg","width":1200,"height":628,"caption":"Java Annotations - Examples &amp; Types of Annotations in Java"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/java-annotations\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Java Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/java\/"},{"@type":"ListItem","position":3,"name":"Java Annotations &#8211; Examples &amp; Types of Annotations in Java"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/13248","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=13248"}],"version-history":[{"count":15,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/13248\/revisions"}],"predecessor-version":[{"id":148389,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/13248\/revisions\/148389"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/13270"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=13248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=13248"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=13248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}