コレクション オブジェクトは、コンストラクターを使用して別のコレクション オブジェクトから作成できます。
List<Student> list = new ArrayList<Student>(someStudentList);
春にできること。
<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"
....
この方法で春にアイテムを追加するにはどうすればよいですか?
Set<Student> set= new TreeSet<Student>();
set.add(new Student(5, "Mawia"));
...
コンパレータオブジェクトを受け入れるコンストラクタを使用できるようにします。
Set<Student> set= new TreeSet<Student>(new MyComparator());
set.add(new Student(5, "Mawia"));
...