I'm basically getting two errors and I've seen the inputs from previous help questions. I'm doing pretty much same. Anybody can you please guide me
1. Remove the last string and insert it at the beginning. Rinse and repeat 13 times.
I'm doing it here :
for (int i = 0; i<13; i++){
String s = strings.get(strings.size()-1);
strings.remove(strings.size()-1);
strings.add(0, s);
}
2.The program should display the list, each value on a new line.
I'm doing it here:
for(int i = 0; i<strings.size(); i++){
System.out.println(strings.get(i));
}
package com.codegym.task.task07.task0711;
import java.io.*;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Remove and insert
Remove the last string and insert it at the beginning. Rinse and repeat 13 times.
*/
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
InputStream inputStream = System.in;
Reader inputStreamReader = new InputStreamReader(inputStream);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
ArrayList<String> strings = new ArrayList<String>();
for (int i = 0; i<5; i++){
strings.add(0, bufferedReader.readLine());
}
for (int i = 0; i<13; i++){
String s = strings.get(strings.size()-1);
strings.remove(strings.size()-1);
strings.add(0, s);
}
for(int i = 0; i<strings.size(); i++){
System.out.println(strings.get(i));
}
}
}