This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Using any java collection to capture below data
1. Furniture of a house that contains items made out of wood, plastic and glass.
2. Should be able to get total size of items in the collection
3. Also, We need to specifically count items depending on the material.
Welcome to JavaRanch. We don't like doing other people's homework here, but we do like helping others to learn, so that they can do their homework themselves. So, it doesn't really work well if you just post your homework assignment and say "I have no idea, will somebody please do this for me?".
Have you tried writing some code yourself? Where exactly did you get stuck?
If you don't know how collections work in Java, have a look at this excellent tutorial: Collections (written by Joshua Bloch, the guy who implemented the collections in the Java API himself).
You can create a constructor in the Furniture class that takes an item name, color and attributes, and sets those values. Then you don't need the doItem method in your ItemsCollection class - you could just do new Furniture("dressing table", "cream", "medium size");.
Line 19: It is not necessary to initialize obj with new Furniture(); - you're not going to use that Furniture object anyway.
You're using Furniture objects as a key in a Map. For this to work properly, class Furniture must implement proper equals() and hashCode() methods.
Why did you choose for a Map<Furniture, String>? Why not make the material a property of the Furniture object (just like the name, color and attributes), and just store them in a List<Furniture>?
Lines 37-41: You can iterate through collections in a much simpler way, without the need to explicitly deal with an Iterator: