what is annotation class. what is the use of it in java/android.
In iphone Annotation is used to drop a pin on the map..
java has java.lang.Annotation package… what is the use of it? can i have a examples, tutorials,sample codes, etc?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The two concepts are unrelated:
In the Java world, annotations are compile-time tags which are attached to a piece of code. They add metadata to a snippet of code which tools or third parties (or even your own code) can then use later. But they usually don’t affect the way that code runs; that is, if you deleted the annotation, that snippet of code typically shouldn’t behave any differently.
A simple example is marking a piece of code with a copyright notice. Here’s an annotation that we might use for this:
And here’s how we’d attach that metadata to code:
If there’s only one annotation property named
valueyou can omit thevalue =specifier as a shortcut:Otherwise you have to specify it:
If we removed the
@Copyrightannotation, theQuantumCryptographyDecoderwould still work the same as it did before. There just wouldn’t be anyCopyrightmetadata attached to it. But a third-party tool which did some kind of validation (for instance, requiring that all classes whose names included “Quantum” have a@Copyrightnotice attached) could alert you to the missing@Copyrightor take some other useful action.