Anyone can help me? :)
package com.codegym.task.task07.task0708;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
Longest string
*/
public class Solution {
private static List<String> strings;
public static int count;
public static String next;
public static int longest = Integer.MIN_VALUE;
public static String longestString;
public static String secondLongest;
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
strings = new ArrayList<>();
for(int i = 0; i < 5; i++){
String s = reader.readLine();
strings.add(s);
String next = strings.get(i);
for (int a = 0; a < next.length(); a++)
{
if (next.charAt(a) != ' ')
count++;
}
if(count > longest){
longest = count;
longestString = next;
}
if(count == longest){
longest = count;
secondLongest = next;
}
count = 0;
}
System.out.println(longestString);
System.out.println(secondLongest);
}
}