I’ve done some searching but I wasn’t able to find a valid solution. I have an arraylist storing Strings such as gum, socks, OJ, dog food…
I am having trouble iterating the list to determine the total number of differnt types of items.
ie.
ArrayList<String> Store = new ArrayList<String>();
this.Store.add("Gum");
this.Store.add("Gum");
this.Store.add("Socks");
this.Store.add("Candy");
The list has 4 total items, but only three different kinds of items (Gum, Sucks, Candy).
How would I design a method to calculate the 3?
What Bhesh Gurung said, but in code:
If what you actually have is
StoreItemsand need to go throughgetName()then I would do