I can't seem to be able to even initialize N and M right. I have looked at answers to other questions and tried them but nothing seems to work. My code seems to almost work. Need to know what I'm missing here.
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));
int N = Integer.parseInt(reader.readLine());
int M = Integer.parseInt(reader.readLine());
ArrayList<String> list = new ArrayList<String>();
for(int i = 0; i<N; i++){
String s = reader.readLine();
list.add(s);
}
for(int i = 0; i<M; i++) {
list.add((N), list.get(i));
}
for(int i = 0; i<M; i++){
list.remove(i);
}
for (String s : list){
System.out.println(s);
}
//write your code here
}
}