Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.lang.reflect.Field;
- import java.lang.reflect.Method;
- class TestClass {
- private int value;
- public String sa;
- public int getValue() { return value; }
- public void setValue(int valueIn) { this.value = valueIn; }
- }
- public class SimpleComponent {
- public static void main(String[] args) {
- TestClass testClass = new TestClass();
- Object o=new Object();
- char c[]=new char[6];
- for (Field field: testClass.getClass().getDeclaredFields()) {
- System.out.printf("name: %s, type: %s \n", field.getName(),"2");
- }
- testClass.getClass().getField("sa").getType().getCanonicalName().toString().getChars(10, 15, c, 0);
- System.out.println(c);
- for (Method method : testClass.getClass().getDeclaredMethods()) {
- System.out.printf("name: %s, return type: %s \n", method.getName(), method.getReturnType().getCanonicalName());
- }
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment