Java 8 Map: filter value and throw exception if match found
<p>I'm trying to find a matching value in a Map and if found, I need to throw an IllegalArgumentException. My code is as follows:</p>

<pre><code>final String stringToBeMatched = "someRandomString"; 

map.values()
   .stream()
   .filter(a -&gt; stringToBeMatched == a.getField())
   .findAny()
   .ifPresent(a -&gt; throw new IllegalArgumentException());
</code></pre>

<p>I get a syntax error on token "throw". I'm not sure where I'm going wrong. </p>