#问题如图:#解决如图:#请问这该如何办?myeclipse是不是要配置什么呢?#代码如下:
//: arrays/ArrayOfGenerics.java
// It is possible to create arrays of generics.
import java.util.*;
import java.util.List;public class ArrayOfGenerics {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
List<String>[] ls;
List[] la = new List[10];
ls = (List<String>[])la; // "Unchecked" warning
ls[0] = new ArrayList<String>();
// Compile-time checking produces an error:
//! ls[1] = new ArrayList<Integer>(); // The problem: List<String> is a subtype of Object
Object[] objects = ls; // So assignment is OK
// Compiles and runs without complaint:
objects[1] = new ArrayList<Integer>(); // However, if your needs are straightforward it is
// possible to create an array of generics, albeit
// with an "unchecked" warning:
List<BerylliumSphere>[] spheres =
(List<BerylliumSphere>[])new List[10];
for(int i = 0; i < spheres.length; i++)
spheres[i] = new ArrayList<BerylliumSphere>();
}
} ///:~javamyeclipse
//: arrays/ArrayOfGenerics.java
// It is possible to create arrays of generics.
import java.util.*;
import java.util.List;public class ArrayOfGenerics {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
List<String>[] ls;
List[] la = new List[10];
ls = (List<String>[])la; // "Unchecked" warning
ls[0] = new ArrayList<String>();
// Compile-time checking produces an error:
//! ls[1] = new ArrayList<Integer>(); // The problem: List<String> is a subtype of Object
Object[] objects = ls; // So assignment is OK
// Compiles and runs without complaint:
objects[1] = new ArrayList<Integer>(); // However, if your needs are straightforward it is
// possible to create an array of generics, albeit
// with an "unchecked" warning:
List<BerylliumSphere>[] spheres =
(List<BerylliumSphere>[])new List[10];
for(int i = 0; i < spheres.length; i++)
spheres[i] = new ArrayList<BerylliumSphere>();
}
} ///:~javamyeclipse
解决方案 »
- java 编码
- 上传时候,如何判断图片宽高
- 求新手看的java书
- keyTest.java:9: 警告:[unchecked] 对作为普通类型 java.util.Hashtable 的成员的 put<k,v>的调用未经检查
- 新手跪求:JAVA有哪些编译器?
- 请教关于学习方向的问题
- 很容易得分的三个JAVA基础问题。
- 目标:减少HIBERNATE工作量,不重复写DAO,目前只使用SPRING MVC+Hibernate
- 我想applet充满整个浏览器窗口(四周没有空隙),如何实现
- 求关于java类反射的内容,在网上找了好半天居然没有看到,大家帮我找找谢谢了
- 菜鸟学java,帮忙做三道题
- 怎么用多线程post得到的验证码显示在窗体上
性别:男
注册日期:2009年11月04日吐槽下