i cant figure it out
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 {
ArrayList<String> list = new ArrayList<String>();
BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
int lng = 0;
int shrt = 0;
for(int j=0; j<10; j++){
list.add(rd.readLine());//write your code here
}
String shortest = list.get(0);
for(int i=1; i<10; i++){
if (list.get(i).length()<shortest.length())
shortest = list.get(i);
shrt = i;
}
String longest = list.get(0);
for(int i =1; i<10; i++){
if (list.get(i).length()>longest.length())
longest = list.get(i);
lng = i;
}
if (shrt<lng)
System.out.println(list.get(shrt));
else
System.out.println(list.get(lng));
}
}