I have failed 3 and 4 conditions:
Remove the last string and insert it at the beginning. Rinse and repeat 13 times.
The program should display the list, each value on a new line.
public class Solution {
public static void main(String[] args) throws Exception {
Reader r = new InputStreamReader(System.in);
BufferedReader reader = new BufferedReader(r);
ArrayList<String> list = new ArrayList<>();
for (int i = 0; i <5 ; i++) {
list.add(0, reader.readLine());
}
for (int i = 0; i <13 ; i++) {
String s = list.get(4);
list.remove(4);
list.add(0,s);
}
for (String s : list) {
System.out.println(s);
}
}
}
package com.codegym.task.task07.task0711;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
/*
Remove and insert
*/
public class Solution {
public static void main(String[] args) throws Exception {
Reader r = new InputStreamReader(System.in);
BufferedReader reader = new BufferedReader(r);
ArrayList<String> list = new ArrayList<>();
for (int i = 0; i <5 ; i++) {
list.add(0, reader.readLine());
}
for (int i = 0; i <13 ; i++) {
String s = list.get(4);
list.remove(4);
list.add(0,s);
}
for (String s : list) {
System.out.println(s);
}
}
}