title: How to count the occurrence of a given object in a list?
body: <p>for eg I have a list and a class called Sample: 
  The list is :</p>
  
  <pre><code>List&lt;Object&gt; testList = new ArrayList&lt;&gt;();
  testList.add("a");
  testList.add("b");
  testList.add(new Sample());
  testList.add(new Sample());
  </code></pre>
  
  <p>How can I get the count of occurrences of Object Sample from the list?</p>