title: Monads with Java 8
body: <p>In the interests of helping to understand what a monad is, can someone provide an example using java ? Are they possible ?</p>
  
  <p>Lambda expressions are possible using java if you download the pre-release lambda compatible JDK8   from here <a href="http://jdk8.java.net/lambda/" rel="noreferrer">http://jdk8.java.net/lambda/</a></p>
  
  <p>An example of a lambda using this JDK is shown below, can someone provide a comparably simple monad ?</p>
  
  <pre><code>public interface TransformService {
          int[] transform(List&lt;Integer&gt; inputs);
      }
      public static void main(String ars[]) {
          TransformService transformService = (inputs) -&gt; {
              int[] ints = new int[inputs.size()];
              int i = 0;
              for (Integer element : inputs) {
                  ints[i] = element;
              }
              return ints;
          };
  
          List&lt;Integer&gt; inputs = new ArrayList&lt;Integer&gt;(5) {{
              add(10);
              add(10);
          }};
          int[] results = transformService.transform(inputs);
      }
  </code></pre>