Idk what I'm missing here.
package com.codegym.task.task07.task0712;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;
/*
Shortest or longest
*/
public class Solution {
public static void main(String[] args) throws Exception {
ArrayList<String> list = new ArrayList<>();
Scanner sc = new Scanner(System.in);
for (int i=0; i<10; i++)
{
list.add(i, sc.nextLine());
}
// int shortt = list.get(0).length();
//int longg = list.get(0).length();
int shortindex=0;
int longindex=0;
String shortt = list.get(0);
String longg = list.get(0);
for(int i=1; i<10; i++)
{
if(shortt.length() > list.get(i).length());
{shortt = list.get(i);
shortindex=i;}
}
for(int i=1; i<10; i++)
{
if (longg.length() < list.get(i).length())
{longg = list.get(i);
longindex = i;}
}
/*if(shortindex < longindex)
{System.out.println(list.get(shortindex));}
else
System.out.println(list.get(longindex));
*/
String s = (shortindex > longindex) ? list.get(longindex) : list.get(shortindex);
System.out.println(s);
//write your code here
}
}