I Somehow Managed To Remove The First 4 Elements But How Do I Add Them Now At Last.
The Output of This Program is As Follows:
[cat, dog, program, car]
While The Desired Output is:
[cat, dog, program, car, father, mother, son, daughter]
package com.codegym.task.task07.task0720;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Shuffled just in time
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
//write your code here
ArrayList<String> list = new ArrayList<>();
int N = Integer.parseInt(reader.readLine());
int M = Integer.parseInt(reader.readLine());
for(int i = 0; i<N; i++){
String s = reader.readLine();
list.add(s);
}
for(int i = 0; i<M; i++){
list.remove(0);
}
System.out.println(list);
}
}