I have to store a product and its corresponding price. Which of the below methods would be better:
Method 1:
public class Product { String productName; Integer productCost; } Method 2:
Map<String, Integer> product. I assumed that using Map make things easier but still I was suggested to use value Object.
Is there any advantage of using Method 1 over Method 2 in terms of memory and performance? In what situation we can use these two methods?
HashMap, which is much worse than what you describe here. Feel free to ignore it ;-)