What is the correct way to use Mockito's generic `any()` method instead of `anyObject()`?

Use ArgumentMatchers.any() (Alternative):

import static org.mockito.ArgumentMatchers.any;

IBar bar = mock(IBar.class);
...
verify(bar).doStuff(any(Foo[].class));

Explanation: This is essentially the same as the first solution but uses the ArgumentMatchers.any() from the Mockito library’s static import. This method is also generic, and it works in the same way as any(Foo[].class), providing a clean and readable solution.