Just don't expect the compiler to do anything special with them. There are only three annotations recognized by Oracle's compiler, and it's not a coincidence they are all located in the java.lang package; they are @Override, @Deprecated and @SuppressWarnings. Some IDEs add support for their own annotations to their own compilers. An example is the @NotNull annotation of IntelliJ IDEA.
You have not really described what you are trying to do. This makes it almost impossible to help you, as Annotations can cover chapters in books. But to give you a very simple example, I could create a simple annotation like:
Thanks for the reply, could you please let me know how can I learn annotations in deep, are there any books or any tutorials available? I am really curious to learn it but i could not find anything satisfactory on internet.
Thanks for your guidance.
Joined: Sep 09, 2008
author and jackaroo
One of the best books (and not only for annotations - it is one of the best books a Java developer can have) is Effective Java (2nd Edition). It has several sections on annotations, and effectively shows how to create a framework such as JUnit using annotations.
Java (A Beginner's Tutorial) also has a chapter on annotations. However the link I gave you is for the Kindle edition, and while I know it is also available under Safari, I don't know if hard copy books are still available.