Haben Sie eine ArrayList so. Wanna finden, wie viele Werte wiederholt werden: Beispiel: Person: 4-mal, Mädchen: 4malAndroid finden Wiederholungswerte in ArrayList
public ArrayList<String> new_contains_all= new ArrayList<>();
...
[[laying, beautiful, brushing, group, young, head, bed, close, couple, female, teeth, white, indoor, pair, holding, sunglasses, stuffed, wearing, posing, dress, person, hair, standing, looking, girl, red, playing, made, top, woman, lady, hat, clothing, goggles, people],
[person, hair, young, shirt, looking, phone, girl, white, glasses, food, sunglasses, wearing, woman, hat], [blue, beautiful, person, cake, standing, young, shirt, black, female, board, girl, white, photo, holding, ready, wearing, top, posing, woman, lady, smiling, clothing, dress, suitcase], [street, clock, light, stop, sign, red, text, sitting,
man, photo, traffic], [blue, person, young, looking, phone, sitting, female, girl, photo, computer, using, red, laptop, holding, glasses, food, sunglasses, wearing, top, woman, lady, hat]]
Benachrichtigen, dass das Array haben innerhalb 5 Elemente.
Bereits versucht, das sollte für einfache ArrayList arbeiten, aber mit mehr als 1 String pro Element ist es gruselig, ich weiß, die Lösung muss ein anderes bucle in Schlüssel implementieren, aber so müde für heute:/vielleicht jemand blinzelt meine Meinung: P
List<String> l = new_contains_all;
Set<String> s = new HashSet<String>(l);
for (String key : s) {
int count = Collections.frequency(l, key);
if (count > 1)
System.out.println("Found '" + key + "' " + count + " times."+"key: "+key.toString()+"l: "+l.toString());
}
Hinweis: wirklich schlecht Namensgebung Sie dort ankamen. A) Sie verwenden nicht _ für Java-Namen (außer für SOME_CONSTANT) B) einzelne Charakternamen sind einfach schlecht; ihr einziger platz wäre einige für loop int counter ich, j, ... – GhostCat
Danke für die Antwort, war nur ein Test mit zufälligen Namen, und @marmor ist nicht das gleiche Problem, ofc ich sah bereits diesen Eintrag – KashMalaga