The code is almost as Task 0708 except for the ArrayList initialization which is accepted as First step. running without verification works fine. verification says it is not reading 5 inputs from keyboard. I need some clarification.
package com.codegym.task.task07.task0709;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Expressing ourselves more concisely
*/
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
ArrayList<String> strings = new ArrayList<String>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for(int i = 0; i<5; i++){
strings.add(reader.readLine());
}
int m = 1;
for(int i = 1;i<5;i++){
if(strings.get(i).length()<=strings.get(0).length()) {
strings.add(0, strings.get(i));
strings.remove(i+1);
}
}
for(int i = 1;i<5;i++)
if(strings.get(i).length()==strings.get(0).length())
m++;
for(int i=0; i<m; i++)
System.out.println(strings.get(i));
}
}