【发布时间】:2015-01-28 18:01:28
【问题描述】:
我需要以下类是可序列化的。
package helpers;
public class XY implements Comparable<XY>
{
public int x;
public int y;
public XY (int x, int y)
{
this.x = x;
this.y = y;
}
public int compareTo( XY other )
{
String compare1 = this.x + "-" + this.y;
String compare2 = other.x + "-" + other.y;
return compare1.compareTo( compare2 );
}
public String toString()
{
return this.x + "-" + this.y;
}
}
截至目前,我无法将其作为具有输出流的对象发送。我尝试实现 Serializable,但没有成功。
【问题讨论】:
-
“我已经尝试实现 Serializable,但它没有成功!”你到底尝试了什么..?你到底被困在哪里了?
-
这应该尽可能简单...发布您的序列化代码。
标签: java serialization outputstream