The task wants me to iterate through the list but if I was allowed to use collections would this display the max and min (length)?
package com.codegym.task.task07.task0712;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Shortest or longest
*/
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
ArrayList<String> list = new ArrayList <String>(10);
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0; i < 10; i++) {
String s = reader.readLine();
list.add(s);
}
System.out.println(Collections.max(list));
System.out.println(Collections.min(list));
}
}