Rico Felix wrote:2. Create a loop to iterate over the String array argument and tokenize each String object in the String array argument using the split() method. (This is to create the fields such as name, productId, etc. which will then be used to create items)
3. Create an Item object using the fields created from splitting the String object and add it to the Item array.
@Abhinav: And I'd go one further and say that both (2)
and (3) should be part of your
Item class - ie, add a:
public Item(String s) { ...
constructor to it. Or possibly even a:
public Item(Scanner scanner) { ...
one (although it would probably be better to make either one a
static factory method).
In general, classes should contain
everything that pertains to them; and that includes constructors/factories to create themselves in whatever way is required.
You may find the
FirstClasses page worth reading on this subject, but I warn you: it's
not short, as it includes quite a lot of other stuff which you may or may not find useful at this stage.
HIH
Winston