-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTestInterface.java
45 lines (40 loc) · 1.5 KB
/
TestInterface.java
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
package interface_fields;
import java.lang.reflect.Modifier;
public class TestInterface {
private static String getModifiers(int modifiers){
StringBuilder returnValue=new StringBuilder();
if(Modifier.isFinal(modifiers)){
if(returnValue.length()>0)returnValue.append(", ");
returnValue.append("final");
}
if(Modifier.isPublic(modifiers)){
if(returnValue.length()>0)returnValue.append(", ");
returnValue.append("public");
}
if(Modifier.isStatic(modifiers)){
if(returnValue.length()>0)returnValue.append(", ");
returnValue.append("static");
}
return returnValue.toString();
}
public static void main(String[] args){
System.out.println("begin");
ITest.DynamicTest dynamicTest=new ITest.DynamicTest();
System.out.println("DynamicTest#getIntValue:"+dynamicTest.getIntValue());
ITest.StaticTest staticTest=new ITest.StaticTest();
ITest.StaticTest2 staticTest2=new ITest.StaticTest2();
System.out.println("DynamicTest:"+getModifiers(ITest.DynamicTest.class.getModifiers()));
System.out.println("StaticTest:"+getModifiers(ITest.StaticTest.class.getModifiers()));
System.out.println("StaticTest2:"+getModifiers(ITest.StaticTest2.class.getModifiers()));
System.out.println("Determinant:"+getModifiers(ITest.determinant.getClass().getModifiers()));
System.out.println("determinant:"+ITest.determinant);
ITest value=new ITest(){
@Override
public Object getObject() {
return "test value";
}
};
System.out.println(value.getObject());
System.out.println("-end-");
}
}