title: java Stream a custom Class
body: <p>I am making a chess game and I am working right now that validates whether the Piece selected by the Player actually belongs to the Player (and not the other player). So I need to check the array of Pieces that belongs to the player and see if the specific Piece is there.</p>
  <p>I recently learned about lambdas and streaming so I decided that this would be a good place to attempt to utilize those rather than a simple enhanced-for loop. But I am getting the following error message-</p>
  <p><code>Cannot invoke stream() on the array type Piece[]</code></p>
  <p>I have only ever used stream for primitive values but my google searches for how to stream objects has failed to turn up relevant information. Anyways, hopefully this isn't a noob question. Here's my code</p>
  <pre><code>public boolean hasPiece(Piece piece) {      
      lambdaContains runCheck = arr -&gt; {
          boolean result = arr.stream().anyMatch(x -&gt; x == piece);
          return result;
      };
      return runCheck.doesHave(team);
  }
  
  
  interface lambdaContains {
      boolean doesHave(Piece[] team);
  }
  </code></pre>
  <p>Edit: it was indeed a dumb error. Lovesh posted the correct answer, which I had tried except I hadn't realized I needed to import java.util.Arrays
  Thanks to all!</p>