m mới bắt đầu học java nên chưa có kinh nghiệm gì, nên mong các tiền bối đi trước cho em vài lời khuyên. trước đây em có học qua về c++ với C và php nhưng không thực sự giỏi cái nào. hiện nay em đang có bài tập lớn về java,mà em thì không có kinh nghiệm gì về nó nên muốn chọn mảng nào dễ hơn để có thể dễ bắt đầu, nếu các anh chị nào đã học qua thì cho em 1 vài lời khuyên với.em xin cám ơn các anh chị trước.
• ! Module 8 – Annotations ""#$%&'()*+(,-")(, +./ • )012 • (3.232 • *12 • "32 • "3"4 516 • .7411provide additional information about existing pieces of data$ • 1413344$*1891 83343.8.331139 3344$ • .32343737$"443 3.848$ • 1133443323..8 .313.23431 3$ • annotation4.81334431$ 3317218$ • Annotation typ17$*1.81334431 43$ • *104.74: // Definition of an Annotation type public @interface TestAnnotation { String value; } // Usage of Annotation @TestAnnotation (value="name") public void display() {} Uses of Annotations • 14.32: – Information for the compiler;..8143 333333$ – Compiler-time and deployment-time processing;23 32343<=>7<231$ – Runtime processing;43..04 34$ • .334?32< 7<41<133344$ (+(+-@* DO DO if the metadata changes the design of the class. if the metadata changes the design of code dealing with class. if the metadata changes the design of the class. if the metadata changes the design of code dealing with class. DON’T DON’T • 2883 .3.. 33 . • 51873 384.$ • 2883 .3.. 33 . • 51873 384.$ "32 • 3A3 – "241 – B3<1@TestAnno • – "2<4343A3$ – ".33:C3 – )04:@TestAnno(“Testing”) • D – "2444.3$ – )144.333.8C3 – @TestAnno(owner=“Stephen”, value=“class scope”) E • F(3 • F+33 • F353 • F*3 • F • F13 [...]... the members of the annotations is of no importance • The decleration of annotation type should be in the same package as the class using the Annotation Module8 - Summary ACCP I7.1 - A GUIDE TO ADVANCED JAVA Module 9 Reflection API Module Obectives 23 Introduction to Reflection API • Reflection is the ability of classes, objects and interfaces to find information about itself • The reflection API are... static void displayArray(Object source){ System.out.println(Array.get(source, 0)); Array.set(source, 0, 100); System.out.println(Array.get(source, 0)); } } Module 9: Summary • In this module, Reflection API, you learnt about: – Introduction to Reflection API – Analysing classes – Working with objects – Manipulating Arrays ... types as well as objects Array and Reflection • The Array class – – Is used to dynamically create and access arrays at runtime Class.isArray() method is used to check whether a particular object is an array • Arrays can be created during runtime by invoking Array.newInstance() method – The newInstance() method specifies a base type and length the Example package reflectiondemo; import java.lang.reflect.Array;... Reflection is the ability of classes, objects and interfaces to find information about itself • The reflection API are used to write development tools, such as debuggers, class browsers and GUI builder • Reflection API is used for the following purposes: – – – Analyzing classes Controlling objects Controlling with arrays 24 Analyzing classes • Retrieving class name: – If an instance of the class is available,... RetentionPolicy.RUNTIME EXAMPLE @Retention(RetentionPolicy.SOURCE) @interface Test_Retention { String v1(); } class RetentionTest { @Test_Retention(v1="Hello") public void thu() {System.out.println("Test annotations" );} } class RetentionAnno {public static void main(String args[]) { new RetentionTest().thu(); } } Custom Annotation for Class • • To create an annotation type for classes, the "@" symbol followed.. .Annotations Used by the Compiler // Javadoc comment follows /** * @deprecated * explanation of why it was deprecated */ @Deprecated static void deprecatedMethod() { } } // mark method as a superclass method . data$ • 1413344$*18 9 1 83343.8.33113 9 3344$ • .32343737$"443 3.848$ • 1133443323..8 .313.23431 3$ • annotation4.81334431$ 3317218$ • Annotation. • ! Module 8 – Annotations ""#$%&'()*+(,-")(, +./ • )012 • (3.232 • *12 • "32 • "3"4 516 • .7411provide. } // Usage of Annotation @TestAnnotation (value="name") public void display() {} Uses of Annotations • 14.32: – Information for the compiler;..8143 333333$ – Compiler-time