```
package com.codegym.task.task07.task0712;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Shortest or longest
*/
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
ArrayList<String> listString = new ArrayList<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0; i < 10; i++) {
listString.add(reader.readLine());
}
int shortest = listString.get(0).length();
int postitionShort = 0;
int positionLong = 0;
boolean firstShort = false;
boolean firstLong = false;
boolean found = false;
int longest = listString.get(listString.size() - 1).length();
for (int i = 0; i < listString.size(); i++) {
if (shortest > listString.get(i).length()) {
shortest = listString.get(i).length();
postitionShort = i;
}
if (longest < listString.get(i).length()) {
longest = listString.get(i).length();
positionLong = i;
}
}
for (int i = 0; i < listString.size(); i++) {
if (i == positionLong) {
firstLong = true;
System.out.println(listString.get(i));
break;
} else if (i == postitionShort) {
firstShort = true;
System.out.println(listString.get(i));
break;
}
}
}
}
```

package com.codegym.task.task07.task0712;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Shortest or longest
*/
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
ArrayList<String> listString = new ArrayList<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0; i < 10; i++) {
listString.add(reader.readLine());
}
int shortest = listString.get(0).length();
int postitionShort = 0;
int positionLong = 0;
boolean firstShort = false;
boolean firstLong = false;
boolean found = false;
int longest = listString.get(listString.size() - 1).length();
for (int i = 0; i < listString.size(); i++) {
if (shortest > listString.get(i).length()) {
shortest = listString.get(i).length();
postitionShort = i;
}
if (longest < listString.get(i).length()) {
longest = listString.get(i).length();
positionLong = i;
}
}
for (int i = 0; i < listString.size(); i++) {
if (found == false) {
if (i == positionLong) {
found = true;
System.out.println(listString.get(i));
} else if (i == postitionShort) {
found = true;
System.out.println(listString.get(i));
}
}
}
}
}

{"several", "strings", "are", "shortest","or", "longest", "then", "consider", "the", "very", "first", "such", "string", "encountered"}The correct output should be "or", but yours output "several".Where did you come up with 14 or 14 million? It says 10 strings. TEN not 14, not 14 million. If it would be 14 as input or 14 million my code would still work. If you enter the 10 words from your sentence it shows the correct output. Yours is not validating at all. I want to help you since you have a problem grasping some simple concepts and reading legacy code (mine in this case). My code is working but not passing the test on the site. Don't know what you are trying to prove to me, your code is not passing either.2. Add 10 strings from the keyboard.