Настала моя очередь задавать вопрос. Данный код не проходит валидацию:
public class Solution {
private static ArrayList<String> strings;
public static void main(String[] args) throws Exception {
String tempString;
int theMostLongValueInTheList = 0;
ArrayList<String> list = new ArrayList();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0; i < 5; i++) {
do {
tempString = reader.readLine();
if(tempString.equals("")){
System.out.println("Введи текст, ёпта.");
}
} while (tempString.equals("")) ;
if(tempString.length() > theMostLongValueInTheList){
theMostLongValueInTheList = tempString.length();
}
list.add(tempString);
}
for(int i = 0; i < list.size(); i++){
if(list.get(i).length() == theMostLongValueInTheList){
System.out.println(list.get(i));
}
}
}
}
Не могу понять почему. package com.javarush.task.task07.task0708;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Самая длинная строка
*/
public class Solution {
private static ArrayList<String> strings;
public static void main(String[] args) throws Exception {
String tempString;
int theMostLongValueInTheList = 0;
ArrayList<String> list = new ArrayList();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0; i < 5; i++) {
do {
tempString = reader.readLine();
if(tempString.equals("")){
System.out.println("Введи текст, ёпта.");
}
} while (tempString.equals("")) ;
if(tempString.length() > theMostLongValueInTheList){
theMostLongValueInTheList = tempString.length();
}
list.add(tempString);
}
for(int i = 0; i < list.size(); i++){
if(list.get(i).length() == theMostLongValueInTheList){
System.out.println(list.get(i));
}
}
}
}