DEV Community

Discussion on: The Difference Between Public and Private in Java

Collapse
 
lluismf profile image
Lluís Josep Martínez

The HellowWorld example is not the best fit to show how public and private work. It's much more clear with typical data structures like Stack, List etc. or with domain entities like Order, Invoice etc.

Collapse
 
renegadecoder94 profile image
Jeremy Grifski

I appreciate the feedback, but I’m not sure I agree (at least with the first part). If we’re talking beginners, they aren’t going to be able to handle data structures beyond arrays (maybe ArrayLists, LinkedLists)—especially data structures in java which leverage generic types. If they knew those things already, then they probably wouldn’t need this article.

As for domain entities, to be quite honest, I’ve never heard that term. Granted, if we’re just talking about user-defined classes, then that’s fair. I just felt like it was important to come full circle on the example at the beginning of the article. When I get the chance, I’ll extend the last section to include a better example. Thanks!