要素を移動するリストの循環

要素を移動するリストの循環

ループ要素を移動させる回転コレクションクラス()を使用し、二番目の引数の方法は、開始位置を指定します。

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

出力

おすすめ

転載: www.cnblogs.com/zxfei/p/11105157.html