Answers for "java pass new array to method"

2

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});
}
Posted by: Guest on February-25-2020
0

java pass new array to method

methodName(new int[]{1, 2, 3}); // Replace int for different types
Posted by: Guest on March-06-2021
0

passing array to function java

public int min(int [] array) {
      int min = array[0];
   
      for(int i = 0; i<array.length; i++ ) {
         if(array[i]<min) {
            min = array[i];
         }
      }
      return min;
   }
int minimum = min(myArray)
Posted by: Guest on October-30-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language