After trying to debug in IDEA, I realized the ArrayList is taking an empty String as the first value. I cannot figure out why, or how to fix this
package com.codegym.task.task07.task0720;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.ArrayList;
/*
Shuffled just in time
*/
public class Solution {
public static void main(String[] args) throws IOException {
Scanner input = new Scanner(System.in);
ArrayList<String> words = new ArrayList<String>();
int N = input.nextInt();
int M = input.nextInt();
//get initial words
for (int i = 0; i < N; i++) {
words.add(input.nextLine());
}
//move shit around
for (int i = 0; i < M; i++) {
String moveThisWord = words.get(i);
words.remove(i);
words.add(moveThisWord);
}
//print stuff
for (String s : words) {
System.out.println(s);
}
}
}