To see this, let's create a brand new method, and in its declaration, we'll have it the same as our existing magic method. However, instead of taking a single integer as input, we'll provide it as input in the integer array:
package advancedmethods;public class AdvancedMethods { public static void main(String[] args) { int[] x = 5; magic(x); System.out.println("main: " + x); } public static void magic(int input) { input += 10; } public static void magic(int[] input) { input += 10; }}
Remember that our array will be named as a single variable, so all we need to do to let Java know that we'd like to pass an array to the function is inform it that the variable being given is an array of a certain type. You'll ...