Java program to find product of two numbers using recursive function

Java program to find product of two numbers using recursive function. This is a Java program that uses recursion to find the product of two numbers. As an input, enter two integer numbers. Then we feed the two specified numbers, along with zero, to the other function, which uses recursion to get numbers one by one to multiply. As a result, the output is the product of the two provided numbers.

import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
int[] a = new int[2];
Scanner s = new Scanner(System.in);
System.out.print("Enter the first number");
a[0] = s.nextInt();
System.out.print("Enter the second number");
a[1] = s.nextInt();
Main obj = new Main();
int mul = obj.multiply(a,0);
System.out.println("Answer:"+mul);
}
int multiply(int x[], int i)
{
if(i < 2)
{
return x[i] * multiply(x, ++i);
}
else
{
return 1;
}
}
}

Enter the first number 45
Enter the second number 56
Answer: 2520