Using Collections in Spring

exceellSnindy

New Member
A collection object can be created from another collection object using constructor.\[code\] List<Student> list = new ArrayList<Student>(someStudentList);\[/code\]Which can be done in Spring.\[code\] <bean id="stdArrayList" class="java.util.ArrayList"> <constructor-arg > <list> <ref bean="student1" /> <ref bean="student2" /> <ref bean="student3" /> </list> </constructor-arg> </bean> <bean id="student1" class="mawia.test.Student" ....\[/code\]How can I do this way of adding item in Spring?\[code\] Set<Student> set= new TreeSet<Student>(); set.add(new Student(5, "Mawia")); ...\[/code\]So that I can use the constructor which accept a comparator object.\[code\] Set<Student> set= new TreeSet<Student>(new MyComparator()); set.add(new Student(5, "Mawia")); ...\[/code\]
 
Top