how to have an array as a parameter in java code example
Example 1: java pass array as method parameter
/*
In java, you can create an array like this:
new int[]{1, 2, 3};
replace `int` with whatever you want
*/
public static void doSomething(int[] list) {
System.out.println("Something is done.");
}
public static void main(String[] args) {
doSomething(new int[]{1, 2, 3});
}
Example 2: how to take array as an argument in java
import java.util.Scanner;
public class ArraysToMethod {
public int max(int [] array) {
}