Online Java Compiler By
JavaTpoint.com
//import statements import java.lang.reflect.*; public class ClassgetConstructorsExample1 { public static void main(String[] args) { try { Class clsfrm = Class.forName("java.awt.Frame"); //take class path as parameter System.out.println("Frame Constructors::"); //print statement Constructor cls[] = clsfrm.getConstructors(); for(int i = 0; i < cls.length; i++) { //loop from I to length System.out.println("Constructor "+ (i+1) + ":: " +cls[i]); } } catch (Exception e) { System.out.println("Exception: " + e); //printing exception object } } }
Output