title: In Java, how to iterate individual elements of an array with a loop and print each of them?
body: <p>I am writing a program that will display the factors of a number generated by user input. I am trying to use an array iterated by a loop. The main method will call the method which carries the array and also print its output based on the user input. </p>
  
  <pre><code>package arrayCalculateFactors;
  
  import java.util.Scanner;
  
  public class ArrayFactors {
  
      public static void main(String[] args) {
          int num = 0;
          int[] factorOutput = CalculateFactors(num); // Call method containing
                                                      // array.
          System.out.println("The factors of your number are " + factorOutput);
      }
  
      public static int[] CalculateFactors(int num) {
          Scanner numInitial = new Scanner(System.in);
          System.out.println("Please enter a number.");
          int numInput = numInitial.nextInt();
          int[] Factors;
          Factors = new int[18];
          for (int i = 1; i &lt;= numInput / 2; i++)
              if (numInput % i == 0) {
  
              }
          return Factors;
  
      }
  } // End class
  </code></pre>
  
  <p>When I run this program it spits out the memory address, not the factors (input of 10 would print 1, 2, 5, 10). How can I modify the loop to iterate every element of the array? Thanks in advance. </p>