Hasn't somebody taught you about toString()? See Joshua Bloch Effective Java 2nd edition=page 51, 3rd edition=page 55.
Warren Griscti wrote:I'm a bit lost regarding the to string() method . . .
Careful: you never know whether you will find something really good or something unhelpful.
Why? Unless you already know where you are going to serialise an object, I think that would probably cause confusion at this stage.
. . . I can use serialisation too. . . .
Warren Griscti wrote:I was doing this to understand me better.
That's a new requirement to me. Can you explain further?
Warren Griscti wrote:I need to have two product types which are consumbles or hardware and they have different input options such as one has an expiry date whereas the other has to have dimensions and weight.
Carey Brown wrote:Using startsWith() to find the ID is an accident waiting to happen. What if you searched on "1"? It would also find "12345". ID should be an int, not a String and you should use an int comparison.
Isn't | a meta‑character which needs escaping?
Carey Brown wrote:. . . String.split("|") . . .
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton