我有一個枚舉如下面方案中所示的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