Ciao a tutti, ho questo metodo preso dalla rete:
ma non sono capace di farlo partire.codice:public static<T> List<List<T>> disposizioni(List<T> linearSet, int k) { List<List<T>> toReturn = new ArrayList<List<T>>(); int[] indexes = new int[k]; indexes[0] = 0; int i = 0; while (i >= 0) { while (i++ < indexes.length - 1) indexes[i] = indexes[i-1]+1; List<T> toAdd = new ArrayList<T>(); for (i = 0; i < k; i++) toAdd.add(linearSet.get(indexes[i])); toReturn.add(toAdd); i = indexes.length - 1; while (i >= 0 && ++indexes[i] == linearSet.size() - (indexes.length-i-1)) i--; } return toReturn; }
Nel main ho un Vector<String> elementi ma come faccio a farlo passare al metodo? E poi, per elencare le disposizioni a video, come faccio?
Grazie!

Rispondi quotando