Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
List<String> basket = Arrays.asList("orange", "apple", "orange", "orange", "apple");
int appleCount = 0;
for (String obj : basket) {
if (obj.equals("apple")) appleCount++;
}
System.out.println("There are " + appleCount + " apples in the basket.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment