#need help with arraylist
39 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @shy estuary! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
You could create a variable to count how many raw oyster specials you have then loop through your list and increment it for each raw oyster special
Also thats only 3 times
you'd have to count them up, i suppose
probably with a map, so like A, B, A gets reduced to A x2, B correctly
or you could store them in a map to begin with, to track their counts directly, rather than using a list
Yeah thats probably a better approach
But it might require some minor refactoring
i didnt take the full screenshot mb
Its ok
is there a website that shows example?
there's an section on the collections api there, with an article on maps
<string, integer>
does it have to be capitalized?
ArrayList<String> orderL = new ArrayList<String, int>();
it needs to be Integer, primitives cannot be used as generics
ok
but yes, capitalized, because they're reference types
Integer is the wrapper class for int
ArrayList<String> orderL = new ArrayList<String, Integer>();
or would i need to add integer on the front one as well
lists and maps are completely different structures
ok so keep it as it is
no
ArrayList<String, Integer> orderL = new ArrayList<String, Integer>();
List<E> list = new ArrayList<>(); or whatever for lists, but that obviously doesn't work to create maps
lists are not maps
read the guide please
Map<K, V> map = new HashMap<>();
with the proper K and V
but i used ArrayList<String> orderL = new ArrayList<String>(); and worked
Map != list