in the list only the two first Strings are the longest
why it doesn't work my code?
package fr.codegym.task.task07.task0708;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
La chaîne la plus longue
*/
public class Solution {
private static List<String> chaines;
public static void main(String[] args) throws Exception {
// initialisation of list chaines
chaines = new ArrayList<String>();
// read 5 String through the keyboard
BufferedReader cIn = new BufferedReader(new InputStreamReader(System.in));
for(int i=0;i<5;i++){
chaines.add(cIn.readLine());//input one String using keyboard
int max = chaines.get(0).length();//setting first reference length value
if(chaines.get(i).length()>=max){//Loop to compare lengths between inputs
System.out.println(chaines.get(i));//print longest String
}
}
}
}