请教一下:使用了未经检查或不安全的操作
我先把源代码贴上:
import java.util.ArrayList;
import java.lang.Integer;
class CustomArrayList1<String> extends ArrayList{
public void method() {
this.add("I Love You");
//this.add(2);
this.add("And You");
}
public void display() {
for( int i = 0; i < this.size(); i++ ) {
System.out.println(" " + this.get(i));
}
}
}
public class Test{
public static void main(String[] args) {
CustomArrayList1<String> test = new CustomArrayList1<String>();
test.method();
test.display();
}
}
编译完之后总是会出现一下警告:
注意: Test.java 使用了未经检查或不安全的操作。
注意: 要了解详细信息,请使用 -Xlint:unchecked 重新编译。
偶知道这是因为自JDK1.5加入了泛型有关的,可是我在创建 CustomArrayList1实例的时候是以 CustomArrayList1<String>的方式来创建的啊,不知道为什么编译后还会出现这样的警告。麻烦哪位大侠告诉我一声。感激了!
[refer=1,五月]我先把源代码贴上:\r\nimport java.util.ArrayList;\r\nimport java.lang.Integer;\r\n\r\nclass CustomArrayList1...[/refer]
[nquote=2007-10-01 02:11,五月]我先把源代码贴上:\r\nimport java.util.ArrayList;\r\nimport java.lang.Integer;\r\n\r\nclass CustomArrayList1...[/nquote]
|