I have a hashmap of type Map<String, List<Integer>> empage
where String
is the name of the department and List
is the list of age of employees who work in that department.
Now for each department I want to divide the age of employees into 5 age categories like (0-20,20-40...and so on).How can I create these 5 list variables for each department dynamically? I mean I cannot hardcode variable name like Finance_grp1
and so on for each department name? So basically I want something like:
for(each departname in empage.keyset())
{
create Arraylist departmentname_grp1
create Arraylist departmentname_grp2
create Arraylist departmentname_grp3
.
.
and so on till 5 groups
}
For Example the structure that I want is something like this:
Department Finance
grp1 for age 0-20
grp2 for age 20-40
and so on till grp5
Department HR
grp1 for age 0-20
grp2 for age 20-40
and so on till grp5
This way for all the department names, I want to group employees age into groups
Also after creating these 5 groups and processing the employee age into categories, I want to variable of type ChartSeries
for each department name which then I will add to create a bar chart.So, I want something like:
for(department_name in empage)
{
ChartSeries department_name = new ChartSeries();
}
Can anyone help me in resolving this issue?
UPDATE: I know that in Java we cannot append dynamic string while creating variables. What I want is the possible solution to this issue and above problem
>`?
– awksp May 10 '14 at 21:13