这是
public class a1111
{
int id;
String name;
double price;
public a1111() {
// TODO Auto-generated constructor stub
super();
}
public a1111(int id) {
super();
this.id = id;
}
public a1111(int id, String name, double price) {
super();
this.id = id;
this.name = name;
this.price = price;
}
public static void main(String[] args) {
}
}
```第一个类:
这是调用它的类:
```java
import java.lang.reflect.*;
public class a2 {
public static void main(String[] args) {
try {
Class c=Class.forName("a1111");
Constructor cons[]=c.getConstructors();
for(Constructor con:cons) {
System.out.println(Modifier.toString(con.getModifiers())+" ");
System.out.println(con.getName());
System.out.println();
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
这是显示的错误:java.lang.ClassNotFoundException: a1111
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at A/A.a2.main(a2.java:7)