当前页面: 开发资料首页 → J2SE 专题 → 在 jdk1.4 下 , int.class 怎么表示。
在 jdk1.4 下 , int.class 怎么表示。
摘要: 在 jdk1.4 下 , int.class 怎么表示。
下面这个程序,在 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 );
}
}
Integer.TYPE
TYPE
public static final Class
TYPE
The Class instance representing the primitive type int.
Since:
JDK1.1
Integer.class, you cannot use int.class under Java 1.4
new Integer(14)