Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

collection rotate

hi,

I was running following example
import java.util.*;

public class aaa {
   public static void main(String[] args) {
      List list = Arrays.asList("one Two three Four five six".split(" "));
      System.out.println("List :"+list);
      Collections.rotate(list, 3);
      System.out.println("rotate: " + list);
   }
}


from link
http://www.tutorialspoint.com/javaexamples/collection_rotate.htm
Iam getting output as
List :[one, Two, three, Four, five, six]
rotate: [Four, five, six, one, Two, three]



I have not understood meaning of output.
>>   Collections.rotate(list, 3);

what above line means.

I see it is not ordered or sorted as well

Any ideas, suggestions, sample code, links, source code highly appreciated. Thanks in advance
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

I see it is not ordered or sorted as well
It is ordered. It's in the order that it appears in. No, it's not sorted, but it doesn't need to be to be rotated
Avatar of gudii9

ASKER

I have not understood meaning of output.
>>   Collections.rotate(list, 3);

what above line means.
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

>>>It means rotate the collection three places to the right

looks to me rotate to left.

How to visualize rotate 3 places to right
Please advise

List :[one, Two, three, Four, five, six]
rotate: [Four, five, six, one, Two, three]