If I have a class like this:
public class Name implements Serializable {
private final String firstName;
private final String lastName;
public Name(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
}
Will its calculated serialVersionUID change if I add another method (and no additional fields)?
For example, adding the method:
public String getFullName() {
return firstName + " " + lastName;
}
Alternatively, is there a nice tool for figuring this out?
Yes, it will change the serialVersionUID
.
You can use the serialver
command line tool - at least in Sun's JDK to calculate the serialVersionUID
for a given compiled class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With