Annotations

Annotations, which are a form of metadata, provide data about a program that is not part of the program itself. Annotations can then be used by the compiler or by your own code via reflection at runtime. Depending on the annotation value, the meaning of the program or data can change.

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.
  • Compile-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.

There are certain annotation are present in both Java and kotlin as part of standard libraries.For example : @SuppressWarnings, @Override

Annotations syntax contain @ sign followed by annotations name, You can apply annotation for classes, functions, properties.

Kotlin enables the user to apply the annotation for files and expression as well, this features is not present in java and some other languages.

Annotations with constructor

To annotate the primary constructor, it is mandatory to mark the constructor with constructor.


class Bucket @SomeAnnotations constructor(full:Boolean){
}	

@JvmName annotations in kotlin

About Author

This article is written by Pavan, who is serving notice period in an MNC, Bangalore. He thought, let the articles speak rather than his image. He is also the same person who created the reporter for Protractor Jasmine

Share this Article Facebook
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions