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

TEST-5 CSS TEST-1

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

TEST-3 HTML TEST-3