hello. i cant get around of what i'm doing wrong. i ran the program just fine, it gives the longest string, it shows all the longest strings, yet the last 2 conditions come false.
any help is appreciated.
package com.codegym.task.task07.task0708;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/*
Longest string
*/
public class Solution {
private static ArrayList <String> strings = new ArrayList<String>();
public static void main(String[] args) throws Exception {
Scanner scanner = new Scanner(System.in);
for (int i = 0; i <5; i++) {
strings.add(scanner.nextLine());
}
int length = 0;
for (int i = 0; i < strings.size(); i++) {
if (strings.get(i).length() > length) length = strings.get(i).length();
}
for (int i = 0; i < strings.size(); i++) {
if (strings.get(i).length() == length) System.out.println(strings.get(i));
}
}
}