28. J2SE 5.0 Annotations

Lab Exercises


    Exercise 1: Override annotation

    더보기



    Exercise 2: Single-member annotation

    더보기



    Exercise 3:Multiple member annotation

    더보기



    Exercise 4: Complex annotation types

    더보기


     

    Exercise 5: Meta annotation

      더보기


      Exercise 6: Reading annotations at runtime

      더보기



      Homework exercise (for people who are taking Sang Shin's "Java Programming online course")


      1. The homework exercise is to create MyOwnAnnotationExample project as following.
      • Create a new annotation called RequestForEnhancement as following
      public @interface RequestForEnhancement {
          int    id();
          String synopsis();
          String engineer() default "[unassigned]";
          String date();    default "[unimplemented]";
      }
      • Use the above annotation in your MyOwnAnnotationExample project to a method of your choice - in other words, you are using the above annotation to annotate a method of your choice -  by providing appropriate values.
      • Use Runtime annotation API to retrieve the values of the annotation (as you've done in Exercise 6 above) and display them.
      2. Send the following files to javaprogramminghomework@sun.com with Subject as JavaIntro-javase5annotation.
      • Zip file of the the MyOwnAnnotationExample NetBeans project.  (Someone else should be able to open and run it as a NetBeans project.)  You can use your favorite zip utility or you can use "jar" utility that comes with JDK as following.
        • cd <parent directory that contains MyOwnAnnotationExample directory> (assuming you named your project as MyOwnAnnotationExample)
        • jar cvf MyOwnAnnotationExample.zip MyOwnAnnotationExample (MyOwnAnnotationExample directory should contain nbproject directory)
      • Captured output screen  - name it as JavaIntro-javase5annotation.gif orJavaIntro-javase5annotation.jpg (or JavaIntro-javase5annotation.<whatver graphics format>)
        • Any screen capture that shows that your program is working is good enough.  No cosmetic polishment is required.
      • If you decide to use different IDE other than NetBeans, the zip file should contain all the files that are needed for rebuilding the project - war file with necessary source files is OK.



      저작자 표시

      'BOOK Study > JAVA' 카테고리의 다른 글

      29. J2SE 5.0 Concurrency  (0) 2010/01/17
      28. J2SE 5.0 Annotations  (0) 2010/01/17
      27. J2SE 5.0 Generics  (0) 2010/01/17
      26. J2SE 5.0 Language Features Enhancements  (0) 2010/01/17
      Java SE 5 Language Feature Enhancements  (0) 2010/01/13
      25. Java Threads  (0) 2010/01/11
      Trackback 0 Comment 0