List<Data> list = new ArrayList<Data>();
public class Data{
public int n;
public String p;
public Data(int N, String P) {
n = N;
p = P;
}
}
How can i shuffle the Integer of the Object: Data. So the String stays at the same position, and the Integer get’s shuffled.
Loop through
listand store theintof eachDataobject in a separate list. Shuffle this list usingCollections.shuffle(...). Loop through this new shuffled list and set thenfield of each corresponding member oflistto the new randomintfound in the shuffled list.