Hi, having trouble figuring out why this wont output as expect. Any help would be great
package com.codegym.task.task07.task0720;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
/*
Shuffled just in time
*/
public class Solution {
public static void main(String[] args) throws IOException {
Scanner scan = new Scanner(System.in);
ArrayList<String> list = new ArrayList<String>();
// enter 2 numbers
int N = scan.nextInt();
int M = scan.nextInt();
// System.out.println("Enter " + N + " strings");
// add N amount of strings to array list
for (int i = 0; i < N; i++) {
list.add(scan.nextLine());
}
// Move M amount of numbers from front of list to back of list
for (int i = 0; i < M; i++) {
String s = list.get(i);
list.add(s);
}
// Remve start of list array M times
for (int i = 0; i < M; i++) {
list.remove(0);
}
// Print array
for(String s : list){
System.out.println(s);
}
}
}