Ich habe zwei Arraylist filelistund imgListwelche miteinander in Beziehung, zB „h1.txt“ im Zusammenhang mit „e1.jpg“. Wie kann die Liste imgListnach der Randomisierung von automatisch randomisiert werden fileList? Wenn wir wie in Excel eine bestimmte Spalte sortieren, folgt automatisch die andere Spalte?
String [] file = {"H1.txt","H2.txt","H3.txt","M4.txt","M5.txt","M6.txt"};
ArrayList<String> fileList = new ArrayList<String>(Arrays.asList(file));
String [] img = {"e1.jpg","e2.jpg","e3.jpg","e4.jpg","e5.jpg","e6.jpg"};
ArrayList<String> imgList = new ArrayList<String>(Arrays.asList(img));
//randomized files
Collections.shuffle(fileList);
Ausgabe nach Randomisierung zB:
fileList = {"M4.txt","M6.txt","H3.txt","M5.txt","H2.txt","H1.txt"};
beabsichtigte Ausgabe:
imgList = {"e4.jpg","e6.jpg","e3.jpg","e5.jpg","e2.jpg","e1.jpg"};