pls help me with the solution.
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
int shrt = 0;
int lrg = 0;
ArrayList<String> strings = new ArrayList<String>();
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
for ( int i = 0; i<10; i++ ) {
strings.add(r.readLine());
}
String s = strings.get(0);
String l = strings.get(0);
for ( int i = 1; i <10; i++ ) {
if ( strings.get(i).length() < s.length() ) {
//System.out.println(strings.get(i));
s = strings.get(i);
shrt = i;
}
else if ( strings.get(i).length() > l.length() ) {
//System.out.println(strings.get(i));
l = strings.get(i);
lrg = i;
}
}
//System.out.println(l);
//System.out.println(s);
/* for ( int i = 1; i <10; i++ ) {
if ( strings.get(i).length() >= l )
//System.out.println(strings.get(i));
lrg = i;
}*/
for ( int i = 1; i <10; i++ ) {
if (strings.get(i).length() == l.length()){
System.out.println(strings.get(i));
}
else if (strings.get(i).length() == s.length()) {
System.out.println(strings.get(i));
break;
}
}
}
}