I am a novice programmer and having issues understanding arrays. I have two String arrays:
String[] itemList = {"item1", "item2", "item3",....."item10"}
String[] country = {"US", "UK", "France",....."Germany"}
As you probably understood, the idea is, I should be able to choose an item from itemList
, select a country
and the program should show me how much that specific item costs in that country.
Now, I can use if statement
and say something:
ìf(itemList[i] == "item1" && country[i] == "US"){
//check the price for item1 in the US...}
.
This works alright if we have smaller amount of items, but what if the array of items is too big, like hundreds of thousands? The code will be extremely huge if I go with if statement
for every item. Can you guys suggest a better solution?
Thank you in advance!