Question Index

What will be the output of the following program?

import java.util.*;
public class RotateElements
    public static void main(String[] args)
        List list = Arrays.asList("Pavankalyan Prabhas Nagarjuna Venkatesh Rajanikanth Ram Nitin Krishna Nageshwarrao".split(" "));
        Collections.rotate(list, 5);
        Collections.rotate(list, 3);
        System.out.println("rotate: " + list);

rotate: [Rajanikanth, Ram, Nitin, Krishna, Nageshwarrao, Pavankalyan, Prabhas, Nagarjuna, Venkatesh]
rotate: [Krishna, Nageshwarrao, Pavankalyan, Prabhas, Nagarjuna, Venkatesh, Rajanikanth, Ram, Nitin]
rotate: [Nitin, Ram, Rajanikanth, Venkatesh, Nagarjuna, Prabhas, Pavankalyan, Nageshwarrao, Krishna]
rotate: [Venkatesh, Nagarjuna, Prabhas, Pavankalyan, Nageshwarrao, Krishna, Nitin, Ram, Rajanikanth]



Topic: java.util.Arrays - Class Arrays In Collection Framework

Read this topic
Take test on this topic

Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App