title: Passing array elements between different classes in Java
body: <p>I am having trouble passing the elements in an array that holds names and numbers to another class where calculations will be done. This is what I have for the classes. </p>
  
  <pre><code>public class Employee {
      private int sales;
      private String name;
  
      public Employee(String name, int sales){
          this.name = name;
          this.sales = sales;
      }
      public String getName(){
          return this.name;
      }
      public int getSales(){
          return this.sales;
      }
  }
  </code></pre>
  
  <p>That class is to help store the name and sales for the array. Here is the array in its separate class.</p>
  
  <pre><code>import java.util.Scanner;
  
  public class EmployeeArray {
  
      public static int employee() {
  
          Scanner input = new Scanner(System.in);
  
          int numEmp;
          System.out.println("Enter how may employees to be compared: ");
          numEmp = input.nextInt();
          input.nextLine();
          Employee[] employees = new Employee[numEmp];
  
          for (int i = 0; i &lt; numEmp; i++) {
              System.out.print("Enter your name: ");
              String employeeName = input.nextLine();
              System.out.println();
              System.out.print("Enter your annual sales: ");
              int employeeSales = input.nextInt();
              input.nextLine();
              System.out.println();
  
              Employee employee = new Employee(employeeName, employeeSales);
              employees[i] = employee;
          }
          Employee maxSeller = employees[0];
          for (int i = 0; i &lt; employees.length; i++) {
  
              System.out.println("Employee Name: " + employees[i].getName());
              System.out.println("Total sales: $" + employees[i].getSales());
              System.out.println();
  
              if (maxSeller.getSales() &lt; employees[i].getSales()) {
                  maxSeller = employees[i];
              }
          } 
          System.out.println();
          System.out.println("Top Seller is: " + maxSeller.getName());
          System.out.println("Top Sales are: $" + maxSeller.getSales());
  
          return maxSeller.getSales();
  
      }
  }
  </code></pre>
  
  <p>The array holds the values and returns a top seller called maxSeller and gets the name and sales amount for them. Now the problem I am running into is that in a separate class I need to get the values stored in this array to do some calculations. I have to get sales of maxSeller and compare them to the sales of the other sellers in the array. Form there I am trying to display how much more sales the others need to get to equal or surpass the top seller. That is the problem I am running into. I don't know how to pass the values from this array to the next class so I can do the calculations. Any thoughts?</p>