lundi 16 novembre 2020

How can I random N list from list of list in java

I have (Let's say in python) ListofList = [[1,2],[3,4],[5,6],[7,8],[9,10]]

I want to get 3 random elements(list) (without replacement) from list of list. ex. randomed = [[3,4],[7,8],[1,2]]

my list of list (in java) is

List<ArrayList<Integer>> puzzle = new ArrayList<ArrayList<Integer>>();

and it's look like this now , puzzle = [[0],[0,5],[0,1],[0,1,5],[0,5,6],[0,1,6],[0,4,5],[0,5,10],[0,1,2]]

How can i get it in java ?




Aucun commentaire:

Enregistrer un commentaire