Javatpoint Logo
Javatpoint Logo

Setter Injection with Map Example

In this example, we are using map as the answer for a question that have answer as the key and username as the value. Here, we are using key and value pair both as a string.

Like previous examples, it is the example of forum where one question can have multiple answers.

This class contains three properties, getters & setters and displayInfo() method to display the information.


The entry attribute of map is used to define the key and value information.

This class gets the bean from the applicationContext.xml file and calls the displayInfo() method.

Please Share

facebook twitter google plus pinterest tumbler

Learn Latest Tutorials