I am reading from the keyboard to get the N number. Then reading line N times.
package com.codegym.task.task08.task0822;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
/*
Minimum of N numbers
*/
public class Solution
{
public static void main(String[] args) throws Exception
{
List<Integer> integerList = getIntegerList();
System.out.println(getMinimum(integerList));
}
public static int getMinimum(List<Integer> array)
{
// Find the minimum here
int i = array.indexOf(Collections.min(array));
Integer min = array.get(i);
return min;
}
public static List<Integer> getIntegerList() throws IOException
{
// Create and initialize a list here
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
List<Integer> totatlList = new ArrayList<Integer>();
String s = reader.readLine();
int x = Integer.parseInt(s);
for (int i = 0; i < x; i++)
{
s = reader.readLine();
x = Integer.parseInt(s);
totatlList.add(x);
}
return totatlList;
}
}