I have a Staff class which contains a list of roles for that particular staff member. I also have staffList which holds the staff objects.
How do I get an element from the rolesList for that specific instance of the class?
I have tried:
staffList.get(0).getRolesList().get(0)
Which should be the first element of the rolesList from the first element of the staffList, but it just ruturns null.
I also tried:
rolesList.get(staffList.get(0))
rolesList.getIndexOf(staffList.get(0).getRolesList.get(0)
All return null
If I just get the value direct from the rolesList using get index it will display no problem.
I think it is getting a version of the rolesList but not the one that is in that particular Staff object
I have created a new Staff Member and a role in the roleList then used the list when I construct the staff object, so using the getRolesList method of that object and then get the index it should return the value from within the roleList but it isn't:
private List<Staff> staffList = new ArrayList();
ArrayList<Role> roleList = new ArrayList();
roleList.add(Role.DRIVER);
testDriver = new Staff("Mike", "Joy", roleList);
testStaffList.add(testDriver);
GetRolesList() Code
public List<Role> getRoleList() {
return roleList;
}
I basically want to get the stored Role from the objects rolelist within the testdriver object.
testDriver --> roleList --> Role.DRIVER (or whatever the Role happens to be)