public class House {
List colors = new ArrayList();
public void addPaint(String color)
{
colors.add(color);
}
public void display()
{ String value = "";
for (String color : colors)
value += color + ", ";
value = value.substring(0, value.length()-2);
System.out.println("{ " + value + " }");
}
}
public static void main(String[] args) {
House house1 = new House();
house1.addPaint("Red");
house1.addPaint("Blue");
house1.addPaint("Yellow");
house1.display();
}
// Output: { Red, Blue, Yellow }