-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
55 lines (46 loc) · 1.24 KB
/
Test.java
File metadata and controls
55 lines (46 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
*
*/
package annotationexamples;
import java.lang.reflect.Method;
/**
* @author rutpatel
*
*/
public class Test {
@MyAnnotation
private String reverse(String data) {
return new StringBuilder(data).reverse().toString();
}
public static void main(String[] args) {
Test t = new Test();
System.out.println(t.reverse("olleh"));
System.out.println(MyAnnotation.class.isAnnotation());
System.out.println(Test.class.isAnnotation());
System.out.println("Package Name - " + Test.class.getPackageName());
for (Method m : Test.class.getDeclaredMethods()) {
System.out.print(m.getName() + " - ");
if (m.toString().contains("public")) {
System.out.print("PUBLIC ");
}
if (m.toString().contains("private")) {
System.out.print("PRIVATE ");
}
if (m.toString().contains("static")) {
System.out.print("STATIC ");
}
if (m.toString().contains("final")) {
System.out.print("FINAL ");
}
if (m.toString().contains("protected")) {
System.out.print("PROTECTED ");
}
if (m.toString().contains("default")) {
System.out.print("DEFAULT ");
}
System.out.print("Method\n");
}
String E = "\033[31m", S = "\033[32m", D = "\033[0m";
System.out.println(E + "Red" + D + ", " + S + "Green" + D);
}
}