DEV Community

Discussion on: Make an Immutable Object - in Java

Collapse
 
hackermsl profile image
Mateusz Sławomir Lach

Nice article! However I'm a bit confused. As far as I know it's impossible to use generic types with primitives in Java. Therefore following code won't compile:
private final Optional<int> weight;
instead you should type:
private final Optional<Integer> weight;
am I right? Or maybe it's written in newest version of Java and in Java 13 it's OK?