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 { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); ArrayList<String> strings = new ArrayList<String>(); //write your code here int noOfStrings = Integer.parseInt(reader.readLine()); int shiftStrings = Integer.parseInt(reader.readLine()); for(int i=0;i<noOfStrings;i++){ strings.add(reader.readLine()); } int newArrayLoop = shiftStrings; for(int i=0;i<shiftStrings;i++){ String temp = strings.get(i); String temp1 = strings.get(newArrayLoop); strings.set(i,temp1); strings.set(newArrayLoop,temp); newArrayLoop++; } for(String x:strings){ System.out.println(x); } } } THE INPUT AND OUTPUT AS FOLLOWS INPUT: 10 5 string1 string2 string3 string4 string5 string6 string7 string8 string9 string10 OUTPUT: string6 string7 string8 string9 string10 string1 string2 string3 string4 string5