if(listStr.size == 0){ versus if(listStr.isEmpty()){
<pre><code>List&lt;String&gt; listStr = new ArrayList&lt;String&gt;();

if(listStr.size == 0){

}
</code></pre>

<p>versus</p>

<pre><code>if(listStr.isEmpty()){

}
</code></pre>

<p>In my view one of the benefits of using <code>listStr.isEmpty</code> is that it does'nt check the size of the list and then comapre it to zero, it just checks if the list is empty. Are there any other advantages as I often see <code>if(listStr.size == 0)</code> instead of <code>if(listStr.isEmpty())</code> in codebases. Maybe there is a reason its checked this way that I am not aware of ?</p>
