Write a program to find the minimum element in a array?
This Java Example shows how to find minimum number in an array.
/** * @author Mindclues */ public class MinimumElement { public static void main(String args[]) { int ary[] = { 1, 2, 4, 2, 1, 3, 21, 31 }; int a =ary[0]; for(int i=0; i < ary.length; i++){ if(a > ary[i]){ a = ary[i]; } } System.out.println("Minimum Elemnt in Array is : " +a); } }
Minimum Element in Array is : 1
post a comment