Skip to content

Instantly share code, notes, and snippets.

@abhishek-sisodiya
Last active April 26, 2022 00:33
Show Gist options
  • Save abhishek-sisodiya/f7a8c60f5c64f7da6fa7fbfa85fa24f0 to your computer and use it in GitHub Desktop.
Save abhishek-sisodiya/f7a8c60f5c64f7da6fa7fbfa85fa24f0 to your computer and use it in GitHub Desktop.
for (Object word : elements) {
if (Pattern.compile(Pattern.quote("rain"), Pattern.CASE_INSENSITIVE).matcher(word.toString()).find()) {
descVote.add("Rainy");
iconVote.add("HeavyRain.png");
}
}
MAX_DESC = maxVote(descVote);
MAX_ICON = maxVote(iconVote);
private String maxVote(List list) {
int maxCounter = 0;
String ret = "";
for (int index = 0; index < list.size(); index++) {
int counter = 1;
for (int innerIndex = index + 1; innerIndex < list.size(); innerIndex++) {
if (list.get(index) == list.get(innerIndex)) {
counter++;
}
}
if (maxCounter < counter) {
maxCounter = counter;
ret = list.get(index).toString();
}
}
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment