Ask Experts Questions for FREE Help !
Ask
    youknowwhoo's Avatar
    youknowwhoo Posts: 1, Reputation: 1
    New Member
     
    #1

    Sep 28, 2013, 02:12 AM
    Split a List into a Map
    I need to achieve the following scenario.

    1) Create a Employee Class with empID, department and empName.
    2) Create a List for the employees with different values.
    3) Split the employee list into a map such that the department is the key and value is the list of employees.

    I am stuck with the 3rd point.
    Please find my code below:

    Class Student
    package com.student;

    public class Student {
    private int studentID;
    private String branchName;
    private String studentName;
    private int age;

    public Student()
    {
    this.studentID = 1;
    this.studentName = "default";
    this.branchName = "default";
    this.age = 1;
    }

    public Student(int id,String branch,String stname,int age)
    {
    this.studentID = id;
    this.branchName = branch;
    this.studentName = stname;
    this.age = age;
    }

    }


    Class StudentList
    package com.student;

    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;

    public class StudentList {

    /**
    * @param args
    */
    static List<Student> stList = new ArrayList<Student>();

    public static void populateStudentList(Student student)
    {
    stList.add(student);
    }

    public static void splitList()
    {

    }
    public static void main(String[] args) {
    Student student1 = new Student(1, "IT", "Antara", 23);
    Student student2 = new Student(2, "IT", "Madhuja", 23);
    Student student3 = new Student(3, "IT", "Sukanya", 23);
    Student student4 = new Student(4, "CSE", "Arnab", 23);
    Student student5 = new Student(5, "CSE", "Papia", 23);

    populateStudentList(student1);
    populateStudentList(student2);
    populateStudentList(student3);
    populateStudentList(student4);
    populateStudentList(student5);

    splitList();
    //System.out.println("The Student List Contains:: "+ stList);

    }

    }

Check out some similar questions!

List of songs in The Client List [ 4 Answers ]

Looking for a list of songs played in the movie The Client List

What is the cost price of stock that had stock split, merger and another stock split? [ 0 Answers ]

(1) stock split 7.3839 sh to 14.7669 total cost 475.32 (2) merged total 15.0880 shr @.6611667 ration = 9.9832 total cost 475.32 sh (3) another stock split when it reach 11.0067 to 22.0134shares total cost $593.91 (4) total shares todate 74.595 share. (5) what is the cost basis of the 74.595...

What is the difference between a vicinty map and a location map [ 2 Answers ]

Is there a difference between a vicinty map and a location map

How to map router [ 10 Answers ]

Hi I am Syed Ibramusha I have 2 cisco router , How to map one router to another router can any person help me


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.