I'll be al little pawky here, but please hold on before downvoting and read whole response ;)
First of all it's not true that you can't change final field. In Java you can do almost everything ;) Check this out:
public class Movie {
static class FSK { /* TODO */ }
private String title;
private FSK fsk;
private boolean isRent;
private final int serial;
private static int nextSerial;
Movie(String title, FSK fsk) {
this.title = title;
this.fsk = fsk;
this.serial = nextSerial;
nextSerial++;
}
Movie(Movie that) {
this(new String(that.title), that.fsk);
setFinalSerial(that.serial);
}
void setFinalSerial(int newValue) {
try {
java.lang.reflect.Field field = getClass().getDeclaredField("serial");
field.setAccessible(true);
java.lang.reflect.Field modifiersField = java.lang.reflect.Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(field, field.getModifiers() & ~java.lang.reflect.Modifier.FINAL);
field.set(this, newValue);
} catch (Exception exception) {
throw new RuntimeException(exception);
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Movie m1 = new Movie("title", new FSK());
Movie m2 = new Movie(m1);
System.out.println(m1.serial);
System.out.println(m2.serial);
}
}
But this is only an ugly trick. I guess that your class should look like this:
public class Movie {
static class FSK { /* TODO */ }
private String title;
private FSK fsk;
private boolean isRent;
private final int serial;
private static int nextSerial;
Movie(int serial, String title, FSK fsk) {
this.title = title;
this.fsk = fsk;
this.serial = serial;
}
Movie(String title, FSK fsk) {
this (nextSerial++, title, fsk);
}
Movie(Movie that) {
this(that.serial, that.title, that.fsk);
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Movie m1 = new Movie("title", new FSK());
Movie m2 = new Movie(m1);
System.out.println(m1.serial);
System.out.println(m2.serial);
}
}
The point is that you should create "copy constructor" in which you can set final variable without tricks.