正在加载图片...
class Studentt private string names private string no public Student(String name, String not this name=name. this no=no: Student stu0= new Student(“ Zhangsan”,“200103001”); Constructor c= Student class. getConstructoro; Object[ args= new Object{ Zhangsan”,“200103001”}; Student stul =(Student)c newInstance(args); 个java.lang.reflect.Constructor Class • 类Constructor用于表示类的构造函数 • 该类声明了以下方法用于动态创建类的对象 public Object newInstance(Object[] args) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException class Student{ private String name; private String no; public Student(String name, String no){ this.name=name; this.no=no; } } Student stu0 = new Student(“Zhangsan”, “200103001”); Constructor c = Student.class.getConstructor(); Object[] args = new Object[]{“Zhangsan”, “200103001”}; Student stu1 = (Student)c.newInstance(args);
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有