public static void main(String[] args) {
int[] array = {1,2,3,4,5};
int myPro = product(array);
System.out.println("The Product numbers in the array are = " + myPro);
}
public static int product(int[]array) {
int product = 1;
for(int i=0; i<array.length; i++) {
product = product * array[i];
}
return product;
}
}
//output:
The Product numbers in the array are = 120
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter