VisualBuilder
  Home > Java > Tutorials > Annotations (MetaData) - JDK1.5 Tutorial
Tell a friend
Link to us
Total Members
      Members: 84648
     
Sitemap Forum Chat
Home
JDK1.5 Tutorial Home
1 . Printf in Java from C/C++
2 . ForEach Loop in Java
3 . Variable Arguments in Java
4 . New Enhancements in Thread Class
5 . StringBuilder class in Java5.0
6 . Static Import
7 . Enums in Java-1
8 . Special Classes to Process Enums
9 . Autoboxing
10 . Annotations (MetaData)
11 . Creating User defined Annotation Class
12 . Generics
13 . Annotation Processing Tool ( APT )
14 . More Enhancements in Tiger.
15 . Java Compiler (javac) and Debugger
16 . Java Web Start in J2SE 5.0
17 . General Deployment Enhancements in J2SE 5.0
 
Java Group Home
Java Discussion (273)
Java Members (27593)
Java Resources
Java Source Code (1095)
Java Articles (5)
Java Blogs
Java Jobs
Java Components (84)
Java Books
Java Websites (126)
Java News (103)
Java Q & A (114)
- Java Ask Question
- Java Questions
- Java Unanswered Questions
 
GROUPS
.NET
ASP.NET
.NET
C#
ASP
Visual Basic
Java
Java
JSP
EJB
Other
Delphi
C++
Ajax
UML
JavaScript
PHP
Web Design
Web Hosting
SQL Server
Oracle
Project Management
More Groups

 
LEARNING CENTER
TUTORIALS
.NET
.NET Tutorial
ASP Tutorial
ASP.NET Database Tutorial
ASP.NET Development Tips
ASP.Net Security,Internationalisation And Deployment
ASP.NET Server Controls Tips
ASP.NET Tutorial
C Sharp Tutorial
LINQ
Web Development
Flex Tutorial
HTML Tutorial
Learn AJAX Tutorial
PHP Tutorial
Software Development
Database Tutorial
SQL Tutorial
UML Tutorial
Java
Ant Tutorial
EJB 3 Tutorial
Grails Tutorial
Hibernate Tutorial
Java 1.6 Tutorial
Java Tutorial
Java Web Component Tutorial
Java XML Tutorial
JDBC Tutorial
JDK1.5 Tutorial
JSF Tutorial
JSP And J2EE Design Tutorial
JSP Tutorial
Service-Oriented Architecture (SOA) Tutorial For Managers
Spring Tutorial
Struts Tutorial

RESOURCES
Q & A (436 )
Source Code (3275 )
Articles (11 )
Components (1589 )
News (888 )
Websites (1207 )

SUBMISSIONS
Submit Article
Submit Website
Submit News
Submit Source Code
Submit Component

COMMUNITY
Members Directory
Discussion Forum
Chat

SITE
About Us
Sitemap
Search
Contact Us
Link To Us
Feedback
Tell a Friend
Partners
Advertise


Java jdk15 Tutorial
 Annotations (MetaData)
  << Prev: Autoboxing Next: Creating User defined Annotation Class >>

Many APIs require some information about the data which is to be sent to JVM to work with them. Most of the API's uses the XML files commonly known as deployment descriptor like EJB, JAX-RPC web service etc... Java 5.0 gives an easy way to give that meta data into a java file and JVM then reads that meta data at runtime to do the processing. This mechanism is also same as XDoclet.


 


The Java platform has always had various ad hoc annotation mechanisms. For example the transient modifier is an ad hoc annotation indicating that a field should be ignored by the serialization subsystem, and the @deprecated javadoc tag is an ad hoc annotation indicating that the method should no longer be used. As of release 5.0, the platform has a general purpose annotation (also known as metadata ) facility that permits you to define and use your own annotation types. The facility consists of a syntax for declaring annotation types, a syntax for annotating declarations, APIs for reading annotations, a class file representation for annotations, and an annotation processing tool .


Annotations have a number of uses, among them:



  • Information for the compiler — Annotations can be used by the compiler to detect errors or suppress warnings.

  • Compiler-time and deployment-time processing — Software tools can process annotation information to generate code, XML files, and so forth.

  • Runtime processing — Some annotations are available to be examined at runtime.


Note:- There are three annotation types that are predefined by the language specification itself: @Deprecated , @Override , and @SuppressWarnings


The below example will demonstrate the use of the annotations.


package com.visualbuilder;


 


public class AnnotationExample {


@Deprecated
public void hello(){
    System.out.println("hello");
}
// use a deprecated method and tell compiler not to generate a warning
@SuppressWarnings("deprecation")
public static void main(String ar[]){
    new AnnotationExample().hello();
}
}


Output:-


The program will print the "hello" without any warnings of deprecated methods being used.

  << Prev: Autoboxing Next: Creating User defined Annotation Class >>
Java Jdk15 Tutorial Home
Give feedback and win a prize.

 
   Printer Friendly
   Email to a friend
   Add to my Favourites    
  Download PDF version
   Report Bad Submissions
   Submit Feedback
 
  Delicious   Digg   Technorati   Blink   Furl   Reddit   Newsvine   Google Click each image to add
this page to each site.
 
 
Welcome Guest Signup
MEMBER'S PANEL
EMAIL
PASSWORD
Forgot your password?
New User? Click Here!
 
Resend Activation Email!
 
SEARCH
 
 
LINKS
web conferencing service
Skype vs. sipcall
Gift to Pakistan
 
ADVERTISEMENT
 
PARTNER LIST

More
 
 
 

Home | Login | About Us | Contact Us | Privacy Policy | Advertising