title: Java 8: replace anonymous class with lambda
body: <p>I'm having problem in replacing this particular example:</p>
  
  <pre><code>Consumer consumer = new DefaultConsumer(channel) {
      @Override
      public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body)
              throws IOException {
          String message = new String(body, "UTF-8");
          System.out.println(" [x] Received '" + message + "'");
      }
  };
  </code></pre>
  
  <p>Is it possible to replace that with lambda as it uses non-default constructor for DefaultConsumer?</p>
  
  <p>It's from rabbitMQ java tutorial -> <a href="https://github.com/rabbitmq/rabbitmq-tutorials/blob/master/java/Recv.java" rel="nofollow noreferrer">LINK to whole class</a> </p>