Employee[] staff = new Employee[3];
staff[0] = new Employee("Jackson",3600);
staff[1] = new Employee("Jack",12111);
staff[2] = new Employee("son",3601230);
String userNameAndSalary = "";
// Arrays.sort(staff);
for(Employee e:staff){
ArrayList<Employee> employeeList = new ArrayList<Employee>();
employeeList.add(e);
// Iterator iter = employeeList.iterator();
// while(iter.hasNext()){
// System.out.println(iter.next().hashCode());
// }
for(int i=0; i<employeeList.size();i++){
userNameAndSalary += employeeList.get(i).getName()+"@"+employeeList.get(i).getSalary()+"@@";
//System.out.println("姓名:"+employeeList.get(i).getName()+"工资:"+employeeList.get(i).getSalary());
}
}
String userName = "";
String salary ="";
String[] temp = userNameAndSalary.split("@@");
for (int j=0;j<temp.length;j++){
String[] temp1 = temp[j].split("@");
if(j==0){
userName=temp1[0];
salary = temp1[1];
}else{
userName=userName+","+temp1[0];
salary=salary+","+temp1[1];
}
}
String[] userInfo = userName.split(",");
String[] salaryInfo = salary.split(",");
for(int j=0;j<userInfo.length;j++){
System.out.println("姓名:"+userInfo[j]+"工资:"+salaryInfo[j]);
}
staff[0] = new Employee("Jackson",3600);
staff[1] = new Employee("Jack",12111);
staff[2] = new Employee("son",3601230);
String userNameAndSalary = "";
// Arrays.sort(staff);
for(Employee e:staff){
ArrayList<Employee> employeeList = new ArrayList<Employee>();
employeeList.add(e);
// Iterator iter = employeeList.iterator();
// while(iter.hasNext()){
// System.out.println(iter.next().hashCode());
// }
for(int i=0; i<employeeList.size();i++){
userNameAndSalary += employeeList.get(i).getName()+"@"+employeeList.get(i).getSalary()+"@@";
//System.out.println("姓名:"+employeeList.get(i).getName()+"工资:"+employeeList.get(i).getSalary());
}
}
String userName = "";
String salary ="";
String[] temp = userNameAndSalary.split("@@");
for (int j=0;j<temp.length;j++){
String[] temp1 = temp[j].split("@");
if(j==0){
userName=temp1[0];
salary = temp1[1];
}else{
userName=userName+","+temp1[0];
salary=salary+","+temp1[1];
}
}
String[] userInfo = userName.split(",");
String[] salaryInfo = salary.split(",");
for(int j=0;j<userInfo.length;j++){
System.out.println("姓名:"+userInfo[j]+"工资:"+salaryInfo[j]);
}