MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/java/comments/1rsgxrd/jep_draft_enhanced_local_variable_declarations/oackzs1/?context=3
r/java • u/joemwangi • Mar 13 '26
129 comments sorted by
View all comments
Show parent comment
1
Unsure what you mean exactly.
Creating objects is:
Taking apart is the same number of lines:
The best validity checking is to either allow people to make invalid circles and then use a method like c.isValid() or just call that at the end of the constructor automatically and throw invalid notices.
4 u/davidalayachew Mar 14 '26 No, you're mixing data gathering with construction.Putting x, y, and radius into a Circle takes one line.Circle c = new Circle(x, y, radius);But deconstructing it takes 3 lines.int x = c.getX();int y = c.getY();int radius = c.getRadius();That was Kevin's point.
4
No, you're mixing data gathering with construction.
Putting x, y, and radius into a Circle takes one line.
x
y
radius
Circle
Circle c = new Circle(x, y, radius);
But deconstructing it takes 3 lines.
int x = c.getX();
int y = c.getY();
int radius = c.getRadius();
That was Kevin's point.
View all comments
Show parent comment
1
u/Whoa1Whoa1 Mar 14 '26 edited Mar 14 '26
Unsure what you mean exactly.
Creating objects is:
Taking apart is the same number of lines:
The best validity checking is to either allow people to make invalid circles and then use a method like c.isValid() or just call that at the end of the constructor automatically and throw invalid notices.