D:\java_exercise>java TypeInfoEx10
java.lang.InstantiationException: int
at java.lang.Class.newInstance(Class.java:427)
at TypeInfoEx10.main(TypeInfoEx10.java:8)
Caused by: java.lang.NoSuchMethodException: int.<init>()
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.newInstance(Class.java:412)
... 1 more
public class TypeInfoEx10
{
public static void main (String [ ] args )
{
Class<Integer> intClass = int . class ;
try
{
int i = intClass . newInstance ( ) ;
i =1 ;
System . out .println ( i ) ;
}
catch ( Exception e)
{
e . printStackTrace ( ) ;
}
}
}
偶然的你
相关分类