It's working for one iteration, unable to do it for 13. How to correct it?
package com.codegym.task.task07.task0711;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Remove and insert
1. Create a list of strings.
2. Add 5 strings from the keyboard.
3. Remove the last string and insert it at the beginning. Rinse and repeat 13 times.
4. Use a loop to display the contents, each value on a new line.
*/
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
String ind_con = ""; //individual_content
ArrayList<String> con = new ArrayList<String>(); //1 --- con <- content --- () <- means size not set to any arbitary value!
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for(int i = 0; i < 5; i++) {
ind_con = reader.readLine(); //2
con.add(ind_con); //2 put individual_content into the list of contents
//for(int j = 0; j < 13; j++)
for(int j = 0; j < 13; j++) {
if(i == 4)
con.set(0, con.get(i));
}
}
for(String s : con)
System.out.println(s);
}
}