На сколько я понял, надо, чтобы были найдены самая короткая и самая длинная строка, и вывести ту которая встретилась раньше. Если не так можете поправить меня ? 4 условие не проходит моё решение.
package com.javarush.task.task07.task0712;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Самые-самые
*/
public class Solution {
public static void main(String[] args) throws IOException {
int b, c, i;
ArrayList<String> strochki = new ArrayList<String>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int nomerStrokiKorotkaya, nomerStrokiDlinnaya;
for (i=0; i<10; i++) {
strochki.add(reader.readLine());
}
int minimalDlina=strochki.get(0).length();
int maxDlina=strochki.get(0).length();
String strokaKorotkaya=strochki.get(0), strokaDlinnaya=strochki.get(0);
for (b=0; b<10; b++) {
if (minimalDlina>strochki.get(b).length()) {
minimalDlina=strochki.get(b).length();
strokaKorotkaya=strochki.get(b);
nomerStrokiKorotkaya=b;
}
}
for (c=0; c<10; c++) {
if (maxDlina<strochki.get(c).length()) {
maxDlina=strochki.get(c).length();
strokaDlinnaya=strochki.get(c);
nomerStrokiDlinnaya=c;
}
}
if (b>c) System.out.println(strokaDlinnaya);
else System.out.println(strokaKorotkaya);
//напишите тут ваш код
}
}