Hi I understand the requirements for this program can someone give me example output or can someone explain in a simple term.
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
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> list = new ArrayList<String>();
boolean shortest = false;
for(int i=0;i<10;i++){
list.add(reader.readLine());
}
if(list.get(0).length()<list.get(1).length()){
shortest = true;
}
if(shortest == true){
String temp = list.get(0);
for(int i=2;i<10;i++){
if(temp.length()<list.get(i).length()){
temp = list.get(i);
}
}
System.out.println(temp);
}
else{
String temp = list.get(1);
for(int i=2;i<10;i++){
if(temp.length()>list.get(i).length()){
temp = list.get(i);
}
}
}
}
}