In Java, so che per mescolare un ArrayList, esiste il metodo Collections.shuffle(), tuttavia questo mescola l'intero elenco.Come posso mescolare un intervallo specifico di un ArrayList?
Come posso scrivere un metodo (o, qualcuno può scrivere e mi mostra vero?) Come il seguente:
private ArrayList<AnObject> list;
/**
* Shuffles the concents of the array list in the range [start, end], and
* does not do anything to the other indicies of the list.
*/
public void shuffleArrayListInTheRange(int start, int end)
Piuttosto sorprendente vedere quattro risposte che dicono quasi la stessa cosa. :) – Malcolm