I have these two classes:
class Student
{
String name;
String age ;
}
class Person
{
String name;
String age ;
String grade ;
}
In the code below, I am creating Student objects and setting them inside the ArrayList. Once the data is set in the ArrayList, I need to parse that ArrayList and set the values in another object:
public class Work {
public static void main(String args[]) {
List StudentItems = new ArrayList();
Student stud1 = new Student();
Student stud2 = new Student();
stud1.name = "ABC";
stud1.age = "28";
stud2.name = "XYZ";
stud2.age = "38";
StudentItems.add(stud1);
StudentItems.add(stud2);
Person[] pers = new Person[StudentItems.size()];
for (int i = 0; i < StudentItems.size(); i++) {
pers[i] = new Person();
// I am confused here , could anyone please help
}
}
}