e339. shuffling the elements of a list or array.txt

来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 16 行

TXT
16
字号
Use Collections.shuffle() to randomly reorder the elements in a list. 
    // Create a list
    List list = new ArrayList();
    
    // Add elements to list
    
    // Shuffle the elements in the list
    Collections.shuffle(list);
    
    // Create an array
    String[] array = new String[]{"a", "b", "c"};
    
    // Shuffle the elements in the array
    Collections.shuffle(Arrays.asList(array));

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?