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

Passing Array to method in java

👁 1,277 Views
💻 Practical Program
📘 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

  }
}
                        

🖥 Program Output

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

📘 Explanation

None
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.