I have a class
public class Employee{
public String name;
}
and
public static void main(){
Employee e1= new Employee();
e1.name="AAA";
Employee e2= new Employee();
e2.name="BBB";
Employee e3= new Employee();
e3.name="CCC";
Employee e4= new Employee();
e4.name="DDD";
ArrayList<Employee> al= new ArrayList<>();
al.add(e1);
al.add(e2);
al.add(e3);
al.add(e4);
}
Now, I need to Iterate through the ArrayList and get the name property of each object. How can I do that. is there any direct method to do that???