下面这个程序,在 jdk1.50 下编译没有问题。 但在 jdb1.4 下编译出现如下错误:C:\temp\exc>javac -d . TestStudent.java
TestStudent.java:12: incompatible types
found : int
required: java.lang.Object
Student st = ( Student ) constructor.newInstance( new Object[]{ "abc...." , 18 } );
^
请问这个问题该怎样解决呢?
package com.lgh;import java.lang.reflect.*;public class TestStudent{ public static void main(String[] args) throws Exception{ Class cl = Class.forName( "com.lgh.Student" );
Constructor constructor = cl.getConstructor(
new Class[]{ String.class , int.class } );
Student st = ( Student ) constructor.newInstance(
new Object[]{ "abc...." , 18 } );
//System.out.println( st );
}
}
public static final Class<Integer> TYPE
The Class instance representing the primitive type int. Since:
JDK1.1