If you are reading from a text file, you are stuck with that technique. You have the awkward task of ensuring that the format of the file and the way you are reading it match. You are now coupled to the format of the file, and I think that is unavoidable.
Jay Rex wrote:. . .How would I do that in a better way?
That technique of creating objects is error-prone
Gee, shucks, you got me all 'barrassed!
I see you are up to date with try-with-resources
Thanks to you
Yes. You use the javadoc tool to create an HTML document which you open with a web browser, and you use the documentation comments to guide you about how to use the code.
. . . . Are documentation comments seen in a different light?
. . . Where do I create the static method, inside Test.java or Product.java? Is one more correct than the other? . . .
There isn't a really good name for that sort of class, but how about ProductDemo?
. . . What would be a better name for Test.java?