Maybe there is a different way to write the code that "meets the requirements" but is there anything fundamentally wrong with the way I am getting the answer ????
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> zzz = new ArrayList<>();
int minIndex = 0;
int maxIndex = 0;
BufferedReader j = new BufferedReader(new InputStreamReader(System.in));
for(int i =0;i<10;i++){
zzz.add(j.readLine());
}
for(int i =0;i<zzz.size();i++){
if(zzz.get(i).length()>=zzz.get(maxIndex).length()){
maxIndex=i;
}
}
for(int i =0;i<zzz.size();i++){
if(zzz.get(i).length()<=zzz.get(minIndex).length()){
minIndex=i;
}
}
if(maxIndex>minIndex){
System.out.println(zzz.get(minIndex));
}
else if(minIndex>maxIndex){
System.out.println(zzz.get(maxIndex));
}
}
}