title: How to find max salary with empoyee Id in every particular department in JAVA?
body: <pre><code>/* Save this in a file called Main.java to compile and test it */
  
  /* Do not add a package declaration */
  import java.util.*;
  import java.io.*;
  
  /* DO NOT CHANGE ANYTHING ABOVE THIS LINE */
  /* You may add any imports here, if you wish, but only from the 
     standard library */
  
  /* Do not add a namespace declaration */
  public class Main {
      public static Map&lt;String, Integer&gt; processData(ArrayList&lt;String&gt; array) {
          /*
           * Modify this method to process `array` as indicated in the question.
           * At the end, return the appropriate value.
           *
           * Please create appropriate classes, and use appropriate data
           * structures as necessary.
           *
           * Do not print anything in this method.
           *
           * Submit this entire program (not just this method) as your answer
           */
          Map&lt;String, Integer&gt; retVal = new Map&lt;String, Integer&gt;();
          for (Employee employee : array) {
              int highSalary = retVal.get(employee.getDepartment());
              if (highSalary == null || highSalary &lt; employee.getSalary()) {
                  retVal.put(employee.getDepartment(), employee.getSalary());
              }
          }
          return retVal;
      }
  
      public static void main(String[] args) {
          ArrayList&lt;String&gt; inputData = new ArrayList&lt;String&gt;();
          String line;
          try {
              Scanner in = new Scanner(new BufferedReader(new FileReader("input.txt")));
              while (in.hasNextLine())
                  inputData.add(in.nextLine());
              Map&lt;String, Integer&gt; retVal = processData(inputData);
              PrintWriter output = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
              for (Map.Entry&lt;String, Integer&gt; e : retVal.entrySet())
                  output.println(e.getKey() + ": " + e.getValue());
              output.close();
          } catch (IOException e) {
              System.out.println("IO error in input.txt or output.txt");
          }
      }
  }
  </code></pre>
  
  <p>This is the input.txt file:</p>
  
  <pre><code>22, Rajan Anand, Engineering, 1600000
  23, Swati Patil, Testing, 800000
  27, Vijay Chawda, Engineering, 800000
  29, Basant Mahapatra, Engineering, 600000
  32, Ajay Patel, Testing, 350000
  34, Swaraj Birla, Testing, 350000
  </code></pre>
  
  <p>I've created one Employee class and tried with getter setter but it's not working at. How can I approach this question please help me out</p>
  
  <p>Expected result:</p>
  
  <pre><code>Engineering: 22
  Testing: 23
  </code></pre>
  
  <p>Class definition:</p>
  
  <pre><code>public class Employee {
      private int salary;
      private String department;
      private int employeeId;
      private String name;
  
      public Employee(int salary, String department, int employeeId, String name) {
          this.salary = salary;
          this.department = department;
          this.employeeId = employeeId;
          this.name = name;
      }
  
      public int getSalary() {
          return salary;
      }
  
      public void setSalary(int salary) {
          this.salary = salary;
      }
  
      public String getDepartment() {
          return department;
      }
  
      public void setDepartment(String department) {
          this.department = department;
      }
  
      public int getEmployeeId() {
          return employeeId;
      }
  
      public void setEmployeeId(int employeeId) {
          this.employeeId = employeeId;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  }
  </code></pre>
  
  <p>I created Employee class exclusively by encapsulation but I am gettinng compilation errors. Please help me out with I stuck on this from last 2 days.
  But I want to do it without Employee class</p>