Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

ArrayList question

$
0
0
I have a question concerning array lists. I have a list of arrays and I already have stored a product name called: item, and a 10 digit code for each product. Example: Coffee 0123456789

Now I am attempting to create a method that takes in the code and returns the item. Here is what I have so far.

public String getItem(String userUPC) {
		for(int i = 0; i < itemList.size(); i++) {
			if(userUPC == itemList.get(itemList(i).UPC) {
				return itemList.get(itemList(i).item);
			}
		}
	}


I know this is wrong but I have just recently been introduced to array lists and I am having trouble figuring this out. Just let me know if this is the right idea and what exactly the method is to get the array list "itemList" UPC code and match is to the one entered in the method in order to return the items name.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>