I've currently seen this constructor:
public ImmutableClass( final long id, final String[] arrayOfStrings,
final Collection< String > collectionOfString) {
this.id = id;
this.arrayOfStrings = Arrays.copyOf( arrayOfStrings, arrayOfStrings.length );
this.collectionOfString = new ArrayList<>( collectionOfString );
}
I have never seen something like that before. It was argued that it is for the "Immutability" of the Class and it makes sure that the state can't be modified from outside.
So, does this make sense or what is this?
Furthermore, I wanted to know why the arguments in this code are marked as final?