[cc lang=”java”] try { Class classe = Class.forName(“vesso.model.beans.entitybeans.prim.Cliente”); Field atributos[] = classe.getDeclaredFields(); for (int i = 0; i < atributos.length; i++) { Field atributo = atributos[i]; int mod = atributo.getModifiers(); System.out.format("Atributo#%d: %s, do tipo: %s, com os modificadores: %s, da Classe: %s.%n", i,atributo.getName(),atributo.getType(),Modifier.toString(mod),atributo.getDeclaringClass()); System.out.println("-----"); } } catch (Throwable e) { System.err.println(e); } [/cc] Um grande abraço e muito Suce$$o! Se gostou deixe um...
Obter metodos de uma classe com Reflection...
Escrito por Cesar Barbosa
[cc] try { Class c = Class.forName(“vesso.model.beans.entities.Cliente”); Method m[] = c.getDeclaredMethods(); for (int i = 0; i < m.length; i++) { System.out.println("Nome do metodo: "+m[i].toString()); } } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } [/cc] Um grande abraço e muito Suce$$o! Se gostou deixe um...
Recent Comments