Calculates the multiplication of all elements of an array by calling the method

I need help with the multiplication of my array. This is what I’ve got so far and I’m not sure on how to continue. The question requires I use recursion. The output should look something like this:

The length of your array is: 6

The elements of your array are: 1 2 3 4 5 6

The multiplication of {1, 2, 3, 4, 5, 6} is 720.

I don’t want an exact answer but an explanation of things I can do/research, although you can provide a working code if you would like, thank you.

public static void main(String[] args) {

    Scanner userInput = new Scanner(;

    System.out.printf("The length of your array is: ");
    int Length = Integer.parseInt(userInput.nextLine());
    System.out.printf("The elements of your array are: ");
    int[] myArray = new int[Length];
    //Determines Length of array based on user input
    for (int i = 0; i < Length; i ++) {
        myArray[i] = Integer.parseInt(;
    //Is the defined elements in array, based on user input
    System.out.printf("The multiplication is %s%n", multiplication(myArray, 0, Length - 1));

public static String multiplication(int[] myArray, int startIndex, int endIndex) {

    myArray[] * 1;
    if (startIndex == endIndex)
        return myArray[endIndex] + ".";
        return myArray[startIndex]+ multiplication(myArray, startIndex + 1, endIndex);



  1. The multiplication should return int or long (for multiplication the result will grow very fast)
  2. Remove myArray[] * 1;, no need, 1 is neutral for multiplication
  3. For the stop condition startIndex == endIndex just return the element return myArray[endIndex];. Your recuretion function is f(n) = n * f(n-1)
public static long multiplication(int[] myArray, int startIndex, int endIndex) {
    if (startIndex == endIndex)
        return myArray[endIndex];
        return myArray[startIndex] * multiplication(myArray, startIndex + 1, endIndex);