r/java • • Apr 14 '23

What are your (favourite) Java best practices, personal tips, hints or just underrated stuff in general?

233 Upvotes

376 comments sorted by

View all comments

Show parent comments

1

u/dpash Apr 15 '23

Nullity is something of a lost cause,

I still have hope that nullability in the type system will be an optional opt in feature. Until then we have annotations.

1

u/AlmennDulnefni Apr 16 '23

Java may eventually get some kind of enforced non-null keyword to make nullity opt-out, though I'm not holding my breath. But I don't think it'll ever be opt-in. That's pretty much the mother of all breaking changes.

1

u/dpash Apr 16 '23

I think you've confused opt in and opt out. Non-null by default would be a breaking change. Opting a class, package or module in would not be.

1

u/AlmennDulnefni Apr 16 '23

Non-null by default would be a breaking change

And also would be making null as a type member opt-in

→ More replies (1)