Using an array in another method

Run Settings
LanguageJava
Language Version
Run Command
class Main { //method void (no return) use array from somehwere private static void printArray(int[] intArray){ System.out.println("We sent the following data from one method to another:"); //print individual elements of array using enhanced for loop for(int i=0; i<intArray.length; i++){ System.out.print(intArray[i] + " "); } } public static void main(String[] args) { //integer array int[] intArray = {10,20,30,40,50,60,70,80}; //call the printArray method and use intArray as an argument printArray(intArray); } }
Editor Settings
Theme
Key bindings
Full width
Lines