How to count number of instances of specific class in arraylist?
<p>I have an array list that looks like:</p>

<pre><code>[new Class1(), new Class2(), new Class1(), new Class1()]
</code></pre>

<p>I want to know the most efficient way to extract the number of instances of Class1 in the array list.</p>

<p>For the above example, I want the answer 3.</p>

<p>I am using Java version "1.7.0_79".</p>