alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (LambdaExpr10.java)

This example Java source code file (LambdaExpr10.java) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

block, lambdaexpr10, object

The LambdaExpr10.java Java example source code

/*
 * @test /nodynamiccopyright/
 * @bug 8003280
 * @summary Add lambda tests
 *  check that lambda in array initializers (with wrong type) are correctly rejected
 * @compile/fail/ref=LambdaExpr10.out -XDrawDiagnostics LambdaExpr10.java
 */

class LambdaExpr10 {

    interface Block<T> {
       void m(T t);
    }

    void apply(Object[] obj_arr) { }

    void test1() {
        Object[] arr1 =  { t -> { } };
        Object[][] arr2 =  { { t -> { } } };
    }

    void test2() {
        Object[] arr1 =  new Object[]{ t -> { } };
        Object[][] arr2 =  new Object[][]{ { t -> { } } };
    }

    void test3() {
        apply(new Object[]{ t -> { } });
        apply(new Object[][]{ { t -> { } } });
    }

    void test4() {
        Block<?>[] arr1 =  { t -> t };
        Block<?>[] arr2 =  new Block[]{ t -> t };
        apply(new Block<?>[]{ t -> { }, t -> { } });
    }
}

Other Java examples (source code examples)

Here is a short list of links related to this Java LambdaExpr10.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.