Home Discussion Discuss: Annotations

  • Error or something Missing krishna January 30, 2013 at 6:23 PM

    @Target(ElementType.METHOD) public @interface Test_Element { // Here u define Test_Element but using Test_Element @Test_Target(doTestElement="Hi ! How r you")// But Using Test_Target how ...i want to know that plz public void doTestElement() { System.out.printf("Testing Target Element annotation"); } }

  • Errors on pageHans July 30, 2012 at 1:58 PM

    Hi, to learn a subject it would be helpful if there were no errors in the text (even if they are typos)! 1. Missing @-sign: Defining an annotation (Annotation type) public @interface Example { String showSomething(); } Annotating the code (Annotation) ---> here <--- Example (showSomething="Hi! How r you") public void anymethod() { .... } 2. Wrong annotation name: @Target(ElementType.METHOD) public @interface Test_Element { public String doTestElement(); } Now lets create a class that use the Test_Element annotation: public class Test_Annotations { public static void main(String arg[]) { new Test_Annotations().doTestElement(); } ---> here @Test_Target <--- (doTestElement="Hi ! How r you") public void doTestElement() { System.out.printf("Testing Target Element annotation"); } } I just stopped reading here because I didn't trust the text anymore...

  • typoKate September 19, 2012 at 5:22 PM

    Hi, at the "Target annotation" example, shouldn't use @Test_Element instead of @Test_Target at class Test_Annotations? Regards, Kate Like this: ... public class Test_Annotations { ... @Test_Element(doTestElement="Hi ! How r you") public void doTestElement() { System.out.printf("Testing Target Element annotation"); } }

Post your Comment



Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Related Articles
DMCA.com