站内搜索: 请输入搜索关键词

当前页面: 开发资料首页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)


↑返回目录
前一篇: 初学,请教小问题????????????
后一篇: 求救  关于FOR循环...