Can you help me?
Thanks!
package com.codegym.task.task07.task0712;
import java.util.ArrayList;
import java.util.Scanner;
/*
Shortest or longest
*/
public class Solution {
public static void main(String[] args) throws Exception {
Scanner scanner = new Scanner(System.in);
ArrayList <String> list = new ArrayList <String> ();
for (int i = 0; i < 10; i++){
list.add(scanner.nextLine());
}
String shortest = list.get(0);
int posshortest = 0;
String longest = list.get(0);
int poslongest = 0;
for (int i = 0; i < list.size(); i++){
if (list.get(i).length() < shortest.length()){
posshortest = i;
}
else if (list.get(i).length() > longest.length())
{
poslongest = i;
}
}
if (posshortest < poslongest) {
System.out.println(list.get(posshortest));
}
else
{
System.out.println(list.get(poslongest));
}
}
}