Most efficient way to check if an array contains a value in Java?
<p>I have a similar logic for a method in a Java Class (not the real code, this is simplified for example purposes).</p>

<pre><code>private Boolean method(Boolean booleanValue, SomeObject object) {
  return booleanValue ? Arrays.asList(object.getStringsArray()).contains("string") : false;
}
</code></pre>

<p>A collaborator who assigned himself to check the PR gave the following comment:</p>

<blockquote>
  <p>This is inefficient. It is creating a new data structure only to iterate it and check if there is a certain string.</p>
</blockquote>

<p>The <code>getStringsArray()</code> method returns a <code>String[]</code>, so will using a for-loop be better than <code>Arrays.asList()</code>? </p>

<p>Which way is more efficient to achieve this?</p>