有,說:「不安全的操作」,所以我用-Xlint警告:未選中看到這些操作,但我不明白我在做什麼錯。這些是警告,然後我的代碼謝謝!-Xlint:清洗&建立我的項目在NetBeans未選中時在NetBeans
UploadBean.java:40: warning: [unchecked] unchecked conversion
private final List fileList = Collections.synchronizedList(new ArrayList());
required: List<T>
found: ArrayList
where T is a type-variable:
T extends Object declared in method <T>synchronizedList(List<T>)
UploadBean.java:40: warning: [unchecked] unchecked method invocation: method synchronizedList in class Collections is applied to given types
private final List fileList = Collections.synchronizedList(new ArrayList());
required: List<T>
found: ArrayList
where T is a type-variable:
T extends Object declared in method <T>synchronizedList(List<T>)
UploadBean.java:97: warning: [unchecked] unchecked call to add(E) as a member of the raw type List
fileList.add(fd);
where E is a type-variable:
E extends Object declared in interface List
3 warnings
CODE
//This is line 40
private final List fileList = Collections.synchronizedList(new ArrayList());
//This is line 88
public void doUpload(FileEntryEvent e) {
FileEntry file = (FileEntry) e.getSource();
FileEntryResults result = file.getResults();
for (FileInfo fileInfo : result.getFiles()) {
if (fileInfo.isSaved()) {
FileDescription fd =
new FileDescription(
(FileInfo) fileInfo.clone(), getIdCounter());
synchronized (fileList) {
fileList.add(fd); //This is line 97
}
}
}
}
歡呼