title: How can i process the ArrayList with count, and group by function
body: <p><a href="https://i.stack.imgur.com/QBJCj.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QBJCj.jpg" alt="enter image description here"></a>I was process the arraylist of employees, and need the group by function usage by count of employees, count active employees and count inactive employees. I know how to process the total, but how can i process the arraylist with group by function. </p>
  
  <pre><code>public class Employee {
      private String name;
      private String department;
      private String status;
      public Employee(String name, String department, String status) {
          this.setName(name);
          this.setDepartment(name);
          this.setStatus(status);
      }
      public String getName() {
          return name;
      }
      public String getDepartment() {
          return department;
      }
      public void setName(String name) {
          this.name = name;
      }
      public void setDepartment(String department) {
          this.department = department;
      }
      public String getStatus() {
          return status;
      }
      public void setStatus(String status) {
          this.status = status;
      }
  }
  
  ArrayList&lt;Employee&gt; listEmployee = new ArrayList&lt;Employee&gt;();
  listEmployee.add(new Employee("Ravi", "IT", "active"));
  listEmployee.add(new Employee("Tom", "Sales", "inactive"));
  listEmployee.add(new Employee("Kanna", "IT", "inactive"));
  
  int count = 0;
  for (Employee e : listEmployee) {
      count++;
  }
  System.out.println("Count of Employees" + count);
  </code></pre>
  
  <p>This is the above code i tried to get the count of employees</p>
  
  <pre><code>int count = 0;
  for (Employee e : listEmployee) {
      count++;
  }
  System.out.println("Count of Employees" + count);
  </code></pre>
  
  <p>Please help me to process the data by grouping of department</p>
  
  <p>I am expecting the following output to come:</p>
  
  <pre class="lang-none prettyprint-override"><code>Department total activeCount inactiveCount
  IT         2     1           1
  Sales      1     0           1
  </code></pre>