title: returning two arrays from the same method?
body: <p>I'm trying to make a program that will read the high temperatures for 5 days in city A and city B. I've got to make a method for the cities that will take in all 10 values and return them to the main method. I originally had a single method that would count [0]-[4] as cityA and [5]-[9] as cityB, but my professor said that isn't what he wants (even though the answer is technically right). </p>
  
  <p>It's hard to read his handwriting but this seems to be what he was saying to do.</p>
  
  <p>EDIT- I turned it into a variable-length parameter as per suggestions. still working on getting the return statement right but other than that it looks how I would think it should.   </p>
  
  <p>EDIT#2 - i just realized that string cities was named city in the main method. fixed that but now i'm getting another error. Return value missing? I'm doing pretty much what the book says now - example in book...</p>
  
  <pre><code>printMax(new double[] {1, 2, 3});
  if (numbers.length == 0) {
  System.out.println("No argument passed");
  return;
  </code></pre>
  
  <p><em><strong></em>__<em>_</em>__<em>_</em>__</strong> lastest code</p>
  
  <pre><code>public static double[] getHighTemperatures(String cityName, int numberOfDays) {
      Scanner keyboard = new Scanner(System.in);
      double[] highsForNewYork = getHighTemperatures("New York", 5);
      for (int i = 0; i &lt; numberOfDays; i++)
      highsForNewYork[i] = keyboard.nextDouble();
      return(highsForNewYork);
  }
  </code></pre>
  
  <p><em><strong></em>__<em>_</em>__<em>_</em>__</strong> new code</p>
  
  <pre><code>package program10a;
  
  import java.util.Scanner;
  
  public class compareCities {
  
      public static void main(String[] args) {
          double[] temp = new double[5];
          String[] cities = new String[]{"Miami", "Dallas";
          getCityTemp(temp, cities);
      }
  
      public static double[] getCityTemp(double[] temp, String... cities) {
          Scanner keyboard = new Scanner(System.in);
          if (cities.length == 0) {
              System.out.println("No argument passed.");
              return;
          }
          String cityA = cities[0];
  
          for (int i = 0; i &lt; temp.length; i++) {
              System.out.print("Enter 5 temperatures for City A. ");
              temp[i] = keyboard.nextDouble();
              if (i &lt; cities.length) {
                  cityA = cities[i];
              }
          }
  
          String cityB = cities[0];
  
          for (int i = 0; i &lt; temp.length; i++) {
              System.out.print("Enter 5 temperatures for City B. ");
              temp[i] = keyboard.nextDouble();
              if (i &lt; cities.length) {
                  cityB = cities[i];
              }
          }
      }
  }
  </code></pre>
  
  <p><em><strong></em>__<em>_</em>__<em>_</em>__</strong> below is old code</p>
  
  <pre><code>public static double[] getCityHighA(double[] cityA) {
      Scanner keyboard = new Scanner(System.in);
      for (int i = 0; i &lt; cityA.length; i++) {
          System.out.print("Enter 5 temperatures for City A. ");
          cityA[0] = keyboard.nextDouble();
          cityA[1] = keyboard.nextDouble();
          cityA[2] = keyboard.nextDouble();
          cityA[3] = keyboard.nextDouble();
          cityA[4] = keyboard.nextDouble();
          break;
      }
      return cityA;
  }
  
  public static double[] getCityHighB(double[] cityB) {
      Scanner keyboard = new Scanner(System.in);
      for (int i = 0; i &lt; cityB.length; i++) {
          System.out.print("Enter 5 temperatures for City B. ");
          cityB[0] = keyboard.nextDouble();
          cityB[1] = keyboard.nextDouble();
          cityB[2] = keyboard.nextDouble();
          cityB[3] = keyboard.nextDouble();
          cityB[4] = keyboard.nextDouble();
          break;
      }
      return cityB;
  }
  </code></pre>
  
  <p>Is this the most sensible option, or is it possible to use the same method to pass both cityA and cityB back to the main method? Please note that I have not gotten to Objects yet (I've seen similar topics where Object is used and I do not understand how to go about that). Thanks!</p>