Java Retention Policy, SOURCE,CLASS,RUNTIME

Categories: Java 9 Java 8(JDK1.8)


Retention Policy: A retention policy determines at what point an annotation is discarded. 

It is s specified using Java's built-in annotations: @Retention


1.SOURCE: annotation retained only in the source file and is discarded

          during compilation.Example: @Override, @SuppressWarnings

2.CLASS: annotation stored in the .class file during compilation,

         not available in the run time.

3.RUNTIME: annotation stored in the .class file and available in the run time.Example: @Deprecated

Top Blogs
Java Retention Policy, SOURCE,CLASS,RUNTIME Published at:- Do you know the top new features of Java 9 Published at:- Why to Learn java Programming? Published at:-
R4Rin Team
The content on R4Rin.com website is created by expert teams.