J
June Moore
Hi there,
I have a query regarding array of object.
For example, I have a class Student. I create an array of Student --
private Student[] students;
I also have an ArrayList --
private ArrayList studentList;
From the above example,
How do I get each Student object instance from the students array and
add each Student object to the studentList?
Can I do this?
int siz = students.size(); // not sure if this is correct?
for (int i=0; i < siz; i++)
{
Student student = students;
studentList.add(student);
}
Is this correct? If so, is this efficient? OR can I just CAST students
as an ArrayList without going through the looping?
Thanks,
June...
I have a query regarding array of object.
For example, I have a class Student. I create an array of Student --
private Student[] students;
I also have an ArrayList --
private ArrayList studentList;
From the above example,
How do I get each Student object instance from the students array and
add each Student object to the studentList?
Can I do this?
int siz = students.size(); // not sure if this is correct?
for (int i=0; i < siz; i++)
{
Student student = students;
studentList.add(student);
}
Is this correct? If so, is this efficient? OR can I just CAST students
as an ArrayList without going through the looping?
Thanks,
June...