Display the minimum value of elements in an array





 public class MainClass


PROGRAM:
{
public static void main(String[] args) throws IOException { int[] list = {5, 6, 7, 8, 1, 2, 5, -7, -9, 2, 0}; int min = list[0]; for (int i = 1; i < list.length; i++) { if (list[i] < min) min = list[i]; } System.out.println ("Minimum is " + min); } }
OUTPUT:
Minimum is -9

Comments

Popular posts from this blog

Java Program to create a large array and copy its values equally to two small arrays and display the second array only

Python program to sum up the Salary when the Name and Age matches with subsequent rows.