Skip to content

Instantly share code, notes, and snippets.

@werterzz
Last active March 5, 2022 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save werterzz/dfb0223c4e98b65092dba8f7f11a8c09 to your computer and use it in GitHub Desktop.
Save werterzz/dfb0223c4e98b65092dba8f7f11a8c09 to your computer and use it in GitHub Desktop.
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