r/java • • Jul 19 '26

Disregarding backwards compatibility, would it make sense for String to be a sealed class?

like public sealed class String permits Latin1String, Utf16String instead of the private final byte coder; field

20 Upvotes

26 comments sorted by

View all comments

Show parent comment

1

u/Liskar-dev Jul 29 '26

it's 8 byte saving for each String instance

It's 4 bytes, because Compressed OOPs is on by default