Output is correct.
public class Solution {
private static List<String> strings;
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader re = new BufferedReader(new InputStreamReader(System.in));
strings = new ArrayList<String>();
int n = 0;
for (int i = 0; i < 5; i++)
{
String s = re.readLine();
strings.add(s);
int m = strings.get(i).length();
if (m>=n) {
n = m;
String e = strings.get(i);
System.out.println(e);
}
}
}
}
Can someone explain to me why I am not reaching the conditions?
Archived
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Picvajzmen
6 December 2019, 07:46
Think about the system.out.print that is in the same loop with everything else, what will it print if it loops?
That is the first problem.
+1