Result is ok, where can be mistake?
package pl.codegym.task.task07.task0720;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Przestawiono w samą porę
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
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);
list.add(list.get(i));
}
for (String x : list) // Szybki sposób na zapętlenie wszystkich elementów, tylko dla kolekcji
{
System.out.println(x);
}
}
}