91-9990449935 0120-4256464 |
Constructor Injection with Map ExampleIn this example, we are using map as the answer that have answer with posted username. 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. Question.javaThis class contains three properties, two constructors and displayInfo() method to display the information. applicationContext.xmlThe entry attribute of map is used to define the key and value information. Test.javaThis class gets the bean from the applicationContext.xml file and calls the displayInfo() method.
download this example (developed using MyEclipse IDE)
download this example (developed using Eclipse IDE) |