import java.lang.reflect.Field; import java.lang.reflect.Method; public class Introspection { public void schauNach() { Class a = Auto.class; Method[] meths = a.getMethods(); for (Method m : meths) { System.out.println("Methodenname: " + m.getName()); Class[] params = m.getParameterTypes(); for (int i = 0; i < params.length; i++) System.out.println("Parametertyp: " + params[i]); System.out.println(); } Field[] fields = a.getDeclaredFields(); for (Field f : fields) { System.out.println("Feldname: " + f.getName()); } } public static void main(String[] args) { Introspection in = new Introspection(); in.schauNach(); } } class Auto { int tempo; int radZahl; public Auto(int tempo, int radZahl) { this.tempo = tempo; this.radZahl = radZahl; } public void beschleunige(int menge) { tempo += menge; } public void verzoegere() { tempo--; if (tempo < 0) tempo = 0; } }