未经检查的转换:'java.io.Serialized' 到 'java.util.ArrayList'我的代码是这样的:Activity.javaArrayList<Department> departments = new ArrayList<>();Intent i = getIntent();departments = (ArrayList<Department>) i.getSerializableExtra("DepartmentList");Department.javapublic class Department implements Serializable { private int department_id; private String dept_name; private ArrayList<Course> courses; private ArrayList<Batch>batches; public Department() { } public ArrayList<Batch> getBatches() { return batches; } public void setBatches(ArrayList<Batch> batches) { this.batches = batches; } public int getDepartment_id() { return department_id; } public void setDepartment_id(int department_id) { this.department_id = department_id; } public String getDept_name() { return dept_name; } public void setDept_name(String dept_name) { this.dept_name = dept_name; } public ArrayList<Course> getCourses() { return courses; } public void setCourses(ArrayList<Course> courses) { this.courses = courses; } @Override public String toString() { return dept_name; }}该应用程序运行良好,但我收到以下消息:未经检查的强制转换:'java.io.Serialized' 到 'java.util.ArrayList' 检查信息:向编译器发出未经检查的警告的位置发出信号,例如:void f(HashMap map) { map.put("key", "value"); }提示:将 -Xlint:unchecked 传递给 javac 以获取更多详细信息。
1 回答
开满天机
TA贡献1786条经验 获得超12个赞
您的模型类 Department 应该实现如下所示的 Selialized
public class Department implements Serializable {
private String itemName;
public Department(String itemName) {
this.itemName = itemName;
}
String getItemName() {
return itemName;
}
void setItemName(String itemName) {
this.itemName = itemName;
}
}
希望它能起作用。请尝试一下
添加回答
举报
0/150
提交
取消