Java 通过包传递时,从ArrayList派生的类出现序列化/反序列化问题

Java 通过包传递时,从ArrayList派生的类出现序列化/反序列化问题,java,android,serialization,deserialization,Java,Android,Serialization,Deserialization,让我们假设我有这样的实体 public class Zone implements Serializable { private static final long serialVersionUID = 4671106665561808440L; private String id; public String getId() { return id; } public void setId(String id) {

让我们假设我有这样的实体

public class Zone implements Serializable {

    private static final long serialVersionUID = 4671106665561808440L;

    private String id;

   public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

public static final class List extends ArrayList<Zone>{

    private static final long serialVersionUID = 8772227355586038754L;

    public List() {
        super();
    }

    public List(Collection<? extends Zone> collection) {
        super(collection);
    }

    public List(int capacity) {
        super(capacity);
    }

}
问题是当我试图通过以下代码反序列化时

Zone.List zones = (Zone.List) getIntent().getSerializableExtra(EXTRAS_ZONES);
我有ClassCastException(无法将ArrayList强制转换为Zone.List)。你能解释一下是什么问题吗

试试这个

intent.putSerializable(EXTRAS_ZONES, zones);

一个非常离题的问题。这句话是什么意思,你知道吗?(Zone.List)getIntent().getSerializableExtra(EXTRAS_ZONES)此语句是否同时调用getIntent()和getSerializableExtra(EXTRAS_ZONES)两个方法?Java支持用一条语句调用两个方法吗?
intent.putSerializable(EXTRAS_ZONES, zones);