int:Integer
long:Long
jdk1.5自动装箱,int会自转换为Integer,而Integer是实现了Serializable的,所以可以。
jdk1.4不自动装箱拆箱,所以要手动构造new Integer(int) new Long(long)
/**
* Constructs a newly allocated <code>Integer</code> object that
* represents the <code>int</code> value indicated by the
* <code>String</code> parameter. The string is converted to an
* <code>int</code> value in exactly the manner used by the
* <code>parseInt</code> method for radix 10.
*
* @param s the <code>String</code> to be converted to an
* <code>Integer</code>.
* @exception NumberFormatException if the <code>String</code> does not
* contain a parsable integer.
* @see java.lang.Integer#parseInt(java.lang.String, int)
*/
public Integer(String s) throws NumberFormatException {
this.value = parseInt(s, 10);
你说的是serialVersionUID吧,这个是为了在序列化时区分类的版本
你看一下Serializable的Doc
其中说道
The serialization runtime associates with each serializable class a version number, called a serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization. If the receiver has loaded a class for the object that has a different serialVersionUID than that of the corresponding sender's class, then deserialization will result in an InvalidClassException. A serializable class can declare its own serialVersionUID explicitly by declaring a field named "serialVersionUID" that must be static, final, and of type long