Online Java Compiler By
JavaTpoint.com
import java.lang.reflect.*; public class ClassgetDeclaringClassExample1 { public static void main(String[] args) { Class class1 = Float.class; Method[] mthd = class1.getMethods(); for(int i = 0; i < mthd.length; i++) { Class declaring = mthd[i].getDeclaringClass(); System.out.println("Method = " + mthd[i].toString()); System.out.println(" Declaring class: " + declaring.toString()); } } }
Output