Task 2 of 7 · 0 solved · 7 to go0%
You can read the problem, but answers are checked only for signed-in students. Sign in to answer →

9.2 Generic methods — count occurrences

Total: 0 / 3 pts
Practice mode — check each part and get hints as you go.
Task

Fill in the generic method countOccurrences so that it returns how many elements equal target. It must work for any type.

Compare objects with equals, not ==. The program prints 2 and then 3.

Your solution