for example i have the following
Class Employee {
private String firstname;
private String lastname;
private int Salary;
/* getters and setters*/
}
I built an arrayList for this class and add some employees to it, as following:
ArrayList<Employee> employees = new ArrayList<Employee>();
for (int x=1; x<=10; x++){
Employee e = new Employee();
e.setFirstname("firstname"+ i);
e.setLastname( "lastname"+ i);
e.setSalary( i * 1000);
}
how to get all employees firstname as String array from employees ArrayList dinamically ? what I am asking is something like:
String employeesFirstname = employees.firstname;
can I get like this String array? or I have to build it manually?
Aucun commentaire:
Enregistrer un commentaire