How Spring container deals with Collections?

Here is the below example that shows how the spring container inject values to List and Set collection interfaces during run-time,

public class Shape {
private List shapes;
private Set diffTypeOfShapes;

//Navigating LIST values
public void drawAllShapes() {
for(Shape shape : shapes) {

//Navigating SET values
public void printTypesOfShapes() {
for(String types : diffTypeOfShapes) {

Here the below configuration files, shows how spring container injects the values to the LIST and SET instances in the above code

<bean id="shape" class="com.saravanansivaji.spring.Shape">
<property name="shapes">
<ref bean="triangle"/>
<ref bean="circle"/>

<property name="diffTypeOfShapes">

Happy coding 😀


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: