Last active
April 26, 2022 00:33
-
-
Save abhishek-sisodiya/f7a8c60f5c64f7da6fa7fbfa85fa24f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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