Why the remaining two conditions are not met. Please explain the 3rd requirements.
package com.codegym.task.task07.task0711;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Remove and insert
*/
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
ArrayList<String> list = new ArrayList<String>();
for(int i = 0; i < 5; i++)
{
BufferedReader obj = new BufferedReader(new InputStreamReader(System.in));
list.add(obj.readLine());
}
int p = 1;
int j = 5;
while(p <=13)
{
j--;
String s1 = list.remove(j);
list.add(0,s1);
p++;
if(j==0)
{
j = 5;
}
}
for(int i = 0; i < list.size(); i++ )
{
System.out.println(list.get(i));
}
}
}