Monday 9 September 2013

Is there any advantage of using Value Object over Map in java

Is there any advantage of using Value Object over Map in java

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.
Thanks in advance!

No comments:

Post a Comment