提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
有构造函数
//package com.nowjava; /* 来自 *nowjava.com*/ public class Main { public static void main(String[] argv) throws Exception { Class clazz = String.class; Class paramType = String.class; System.out.println(hasConstructor(clazz, paramType)); } public static boolean hasConstructor(Class clazz, Class paramType) { try { clazz.getConstructor(new Class[] { paramType }); return true; }