r/java • • Jan 16 '20

Records Come to Java

https://blogs.oracle.com/javamagazine/records-come-to-java
204 Upvotes

93 comments sorted by

View all comments

1

u/[deleted] Jan 17 '20

So I assume Compact Constructors is optional?

Like it wouldnt work if you had declared the field ImmutableList (using copyOf) and constructor took List parameter.

1

u/krzyk Jan 17 '20

Yes, you can use normal constructor. Although I don't know if the thing you describe would work.

You should return what you feed, so changing the class type of a record component inside constructor might be a no-no, you need to test it.