# Java Program to Find Minimum Element in an Array using Linear Search

«
»
This is a java program to find the minimum element of the sequence using the technique of linear search. First we assign min equal to the first element of the sequence, then we go on exploring each element of the sequence and compare it with the min element, if less we update min.

Here is the source code of the Java Program to Find Minimum Element in an Array using Linear Search. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.

1. `//This is a java program to find the minimum element using the technique of Sequential Search`
2. `import java.util.Random;`
3. `import java.util.Scanner;`
4. ` `
5. `public class Minimum_Using_Sequential `
6. `{`
7. `    static int N = 20;`
8. `    static int []sequence = new int[N];`
9. ` `
10. `    public static int minSequential()`
11. `    {`
12. `        int min = sequence;`
13. `        for(int i=0; i<N; i++)`
14. `            if(min > sequence[i])`
15. `                min = sequence[i];`
16. ` `
17. `        return min;`
18. `    }`
19. `    public static void main(String args[])`
20. `    {`
21. `        Random random = new Random();`
22. ` `
23. `        for(int i=0; i<N; i++)`
24. `            sequence[i] = Math.abs(random.nextInt(100));`
25. `        System.out.println("The sequence is :");`
26. `        for(int i=0; i<N; i++)`
27. `            System.out.print(sequence[i] + " ");     `
28. ` `
29. `        Scanner sc = new Scanner(System.in);`
30. `        System.out.println("\nThe minimum element in the sequence is : " + minSequential());`
31. `        sc.close();`
32. `    }`
33. `}`

Output:

```\$ javac Minimum_Using_Sequential.java
\$ java Minimum_Using_Sequential

The sequence is :
33 43 61 93 97 31 53 62 58 87 68 61 16 52 12 29 27 63 68 22
The minimum element in the sequence is : 12```

Sanfoundry Global Education & Learning Series – 1000 Java Programs. 