Any helps would be appreciated

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 read = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> list = new ArrayList<>();
for(int i=0;i<10;i++){
list.add(read.readLine());
}
// for the longest string
int longest = list.get(0).length();
for(int i=1;i<10;i++){
if(longest < list.get(i).length()){
longest = list.get(i).length();
}
}
// for the shortest string
int shortest = list.get(0).length();
for(int i=1;i<10;i++){
if(shortest > list.get(i).length()){
shortest = list.get(i).length();
}
}
String s1=null,s2=null;
for(int i=0;i<10;i++){
if(longest == list.get(i).length()){
s1 = list.get(i);
}
}
for(int i=0;i<10;i++){
if(shortest == list.get(i).length()){
s2 = list.get(i);
break;
}
}
if(list.indexOf(s1) < list.indexOf(s2)){
System.out.println(s1);
}else{
System.out.println(s2);
}
}
}