我有一个包含 String[] 数组的 Object 变量,我正在尝试执行以下操作
String[] arr = ((String[])packet.getObject());
然而,我收到了可怕的 ClassCastException。大家需要什么资料?我的数据包类如下所示:
public class Packet implements Serializable {
private static final long serialVersionUID = 1L;
private int type;
private Object object;
public Packet(int type, Object object) {
this.type = type;
this.object = object;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public Object getObject() {
return object;
}
public void setObject(Object object) {
this.object = object;
}
}
有任何想法吗?我正在尝试将对象转换为字符串 []。