-
Notifications
You must be signed in to change notification settings - Fork 0
/
SIOfList
54 lines (44 loc) · 1.41 KB
/
SIOfList
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import java.util.List;
import java.util.Iterator;
class Question{
private int id;
private String name;
private List<String> answers;
//setters and getter
Iterator itr = answer.iterator();
public void display(){
Sytem.out.println(id+" "+name);
System.out.println("answers...");
while(itr.hasNext()){
Sytem.out.println(itr.next());
}
}
}
//applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean>
<property name="id"><value>1</value></property>
<property name="name"><value>What is JAva?</value></property>
<property name="answers"><value>
<list>
<value>Java is a Programin Laguage</value>
<value>Java is platform idepndetn</value>
<value>Java is a island in Indonesia</value>
</lsit>
</value></property>
</bean>
</beans>
public class Test{
public static void main(String[] args){
Resource resource = new ClassPathResource("applicationContext.xml");
BeanFactory factory = new XmlBeanFactory(resource);
Question question = (Question)factory.getBean();
question.display();
}
}