title: Please find how to enter employee details,update,remove,displaying using hashmap
body: <pre><code>import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  import java.util.Scanner;
  import java.util.Set;
  
  class Employee
  {
  private String Id;
  private String Name;
  private String Department;
  private String Salary;
  
  public Employee(String Id, String Name, String Department,
  String Salary)
  {
  this.Id=Id;
  this.Name=Name;
  this.Department=Department;
  this.Salary=Salary;
  }
  
  public String getId() {
  return Id;
  }
  public void setId(String id) {
  Id = id;
  }
  public String getName() {
  return Name;
  }
  public void setName(String name) {
  Name = name;
  }
  public String getDepartment() {
  return Department;
  }
  public void setDepartment(String department) {
  Department = department;
  }
  public String getSalary() {
  return Salary;
  }
  public void setSalary(String salary) {
  Salary = salary;
  }
  
  public String toString() 
  { 
  return this.Id+"\t"+this.Name+"\t\t"+this.Department+"\t\t\t"+this.Salary;
  }
  }
  
  
  public class Assignment4 
  {
  public static void main(String[] args)
  {
  
  try {
  
  Map&lt; String, List&lt;Employee&gt; &gt; m=new HashMap&lt; String, List&lt;Employee&gt; &gt;();
  List&lt;Employee&gt; ListForFinance=new ArrayList&lt;Employee&gt;();
  Scanner scn1=new Scanner(System.in);
  String Id;
  String Name;
  String Department;
  String Salary;
  
  while(true)
  {
  System.out.print("\nThe Choices:\n1&gt;add\n2&gt;modification\n3&gt;remove\n4&gt;display\n\n");
  System.out.println("Enter the choice: ");
  System.out.println("To quit type -1");
  int num=scn1.nextInt();
  if(num == -1)
  {
  break;
  }
  
  switch(num)
  {
  case 1:
  {
  System.out.print("\nDepartment: ");
  Department=scn1.next();
  System.out.print("\nId: ";
  Id=scn1.next();
  System.out.print("\nName: ");
  Name=scn1.next();
  System.out.print("\nSalary: ");
  Salary=scn1.next();
  
  Employee employee1=new Employee(Id,Name,Department,Salary);
  ListForFinance.add(employee1);
  m.put(Department, ListForFinance);
  break;
  }
  
  case 2:
  {
  System.out.println("Type Department to be modified");
  Department=scn1.next();
  System.out.println("Modification values");
  System.out.print("\nId: ");
  Id=scn1.next();
  System.out.print("\nName: ");
  Name=scn1.next();
  System.out.print("\nSalary: ";
  Salary=scn1.next();
  
  Set&lt;String&gt; s=m.keySet();
  Iterator&lt;String&gt; i=s.iterator();
  
  Employee employee1=new Employee(Id,Name,Department,Salary);
  m.get(Department.setId("Id");
  ListForFinance.add(employee1);
  m.put(Department, ListForFinance);
  
  while(i.hasNext())
  {
  System.out.println(i.next());
  }
  
  break;
  }
  
  
  
  case 3:
  {
  System.out.println("=========================================================");
  System.out.println("ID"+"\t"+"NAME"+"\t\t"+"DEPARTMENT"+"\t\t"+"SALARY");
  System.out.println("=========================================================");
  Set&lt;String&gt; s=m.keySet();
  Iterator&lt;String&gt; i=s.iterator();
  
  while(i.hasNext()) 
  {
       String dept=i.next();
       List&lt;Employee&gt; employees=m.get(dept);
       for(int j=0;j&lt;employees.size();j++)
       {
           System.out.print("\n"+employees.get(j)+"\n\n"); 
       }  
  }
  break;
  }
  
  }
  }
  }
  
  catch(Exception e)
  {
  System.out.println("NOTE: \n"+"Please enter specified key format..!!!");
  System.out.println("======================================");
  System.out.println("Now you are Signing out");
  System.out.println("Thank You,Login Again");
  System.out.println("======================================"); 
  }
  }
  }
  
  default:
  System.out.println("=============================================================";
  System.out.print("Wrong key Pressed,please enter the correct key\n";
  System.out.println("Try again...!!!";
  System.out.println("=============================================================";
  }
  }
  } 
  
  
  Please find how to enter employee details,update,remove,displaying using hashmap wherin employee dept is taken as a key and id,name,salary is stored in the values using arraylist ......Currently Iam struck at CASE 2...PLease help me out
  </code></pre>
  
  <p>In CASE 1 i am trying to insert the employee details and in CASE 2 iam trying to modify the values .If i try to put any details with the same Dept it should create new entry...Even i should able to modify it,i am not getting how to do..PLease help me out</p>