Home / Programs / Passing Array to method in java
Programming Example

Passing Array to method in java

👁 1,277 Views
💻 Practical Program
📘 Step by Step Learning
Passing Array to method in java

Program Code

public class ArrayExample {

   static void findmin(int arr[]){
  	 int min=arr[0];

  	 for(int i=1;i<arr.length;i++)
  		  if(min>arr[i])
  			   min=arr[i];

  		 System.out.println("Minimum value: "+min);
     }

   public static void main(String args[]){

   int a[]={22,4,6,7};
   findmin(a);//passing array to method

  }
}

Output

Minimum value: 4
Press any key to continue . . .

Explanation

None

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.