Hello everyone,
I need help with these task, is not verifying, I dont know why, I hope you can help me
Greetings,
Maria :D
package com.codegym.task.task07.task0708;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.io.Reader;
/*
Longest string
*/
public class Solution {
private static List<String> strings;
private static int tempN = 0;
private static String tempS;
private static String tempE;
private static String bigS;
public static void main(String[] args) throws Exception
{
strings = new ArrayList<String>();
Reader r = new InputStreamReader(System.in);
BufferedReader reader = new BufferedReader(r);
for (int i=0; i<5;i++)
{
String name =reader.readLine();
strings.add(name);
}
for(int i=0; i<strings.size(); i++)
{
if (strings.get(i).length() > tempN)
{
bigS = strings.get(i);
tempN = bigS.length();
}
else if (tempN == strings.get(i).length())
{
tempE = strings.get(i);
}
}
System.out.println(bigS);
System.out.println(tempE);
}
}