title: How to find second highest salary in below array list using Java8 streams
body: <pre><code>class Employee
  {
      int id;
       
      String name;
       
      int age;
       
      String gender;
       
      String department;
       
      int yearOfJoining;
       
      double salary;
       
      public Employee(int id, String name, int age, String gender, String department, int yearOfJoining, double salary) 
      {
          this.id = id;
          this.name = name;
          this.age = age;
          this.gender = gender;
          this.department = department;
          this.yearOfJoining = yearOfJoining;
          this.salary = salary;
      }
       
      public int getId() 
      {
          return id;
      }
       
      public String getName() 
      {
          return name;
      }
       
      public int getAge() 
      {
          return age;
      }
       
      public String getGender() 
      {
          return gender;
      }
       
      public String getDepartment() 
      {
          return department;
      }
       
      public int getYearOfJoining() 
      {
          return yearOfJoining;
      }
       
      public double getSalary() 
      {
          return salary;
      }
       
      @Override
      public String toString() 
      {
          return &quot;Id : &quot;+id
                  +&quot;, Name : &quot;+name
                  +&quot;, age : &quot;+age
                  +&quot;, Gender : &quot;+gender
                  +&quot;, Department : &quot;+department
                  +&quot;, Year Of Joining : &quot;+yearOfJoining
                  +&quot;, Salary : &quot;+salary;
      }
  }
  </code></pre>
  <hr />
  <pre><code>List&lt;Employee&gt; employeeList = new ArrayList&lt;Employee&gt;();
           
  employeeList.add(new Employee(111, &quot;Jiya Brein&quot;, 32, &quot;Female&quot;, &quot;HR&quot;, 2011, 25000.0));
  employeeList.add(new Employee(122, &quot;Paul Niksui&quot;, 25, &quot;Male&quot;, &quot;Sales And Marketing&quot;, 2015, 13500.0));
  employeeList.add(new Employee(133, &quot;Martin Theron&quot;, 29, &quot;Male&quot;, &quot;Infrastructure&quot;, 2012, 18000.0));
  employeeList.add(new Employee(144, &quot;Murali Gowda&quot;, 28, &quot;Male&quot;, &quot;Product Development&quot;, 2014, 32500.0));
  employeeList.add(new Employee(155, &quot;Nima Roy&quot;, 27, &quot;Female&quot;, &quot;HR&quot;, 2013, 22700.0));
  
  Optional&lt;Employee&gt; emp = employeeList.stream()
          .collect(Collectors.maxBy(Comparator.comparingDouble(Employee::getSalary)));
  </code></pre>