- Explain that each drawer in a dresser contains different types of clothing, but in the end they’re the same type of item (an item of clothing).
- This is just like when you have an array of a particular type, it contains all the same type of item:
- Clothing [ ] drawer = new Clothing [5];
- drawer[0] = new Clothing("Socks");
- drawer[3] = new Clothing("Shirts");
- Help motivate indexing from zero by having students imagine labeling their drawers.
- Labels should be numbers starting with zero.
- Use a whiteboard to draw out this example to help students visualize.
- Ask students to provide additional examples of structures arrays are like building off of this example to solidify their understanding of arrays.