我有一个枚举如下面方案中所示的java:从枚举映射值到对象
public class Test {
public static void main(String args[]) {
Vector v = new Vector();
v.add("Three");
v.add("Four");
v.add("One");
v.add("Two");
Enumeration e = v.elements();
load(e) ; // **Passing the Enumeration .**
}
}
还有一个Student对象
public Student
{
String one ;
String two ;
String three ;
String four ;
}
我需要通过此枚举为另一种方法,如下所示
private Data load(Enumeration rs)
{
Student stud = new Student();
while(rs.hasMoreElements())
{
// Is it possible to set the Values for the Student Object with appropiate values I mean as shown below
stud.one = One Value of Vector here
stud.two = Two Value of Vector here
stud.three = Three Value of Vector here
stud.four = Four Value of Vector here
}
}
请在此分享你的想法。 谢谢
为什么使用'Vector'和'Enumeration'? ArrayList和Collection更容易处理。 – 2012-03-21 14:46:33