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

Java example source code file (InferenceTest6.java)

This example Java source code file (InferenceTest6.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

inferencetest6, list, sam1, util

The InferenceTest6.java Java example source code

/*
 * @test /nodynamiccopyright/
 * @bug 8003280 8016177
 * @summary Add lambda tests
 *  Missing cast to SAM type that causes type inference to not work.
 * @compile -XDrawDiagnostics InferenceTest6.java
 */

import java.util.*;

public class InferenceTest6 {
    public static void main(String[] args) {
        InferenceTest6 test = new InferenceTest6();
        test.method1(n -> {});
        test.method1((SAM1<String>)n -> {});
        test.method1((SAM1<Integer>)n -> {n++;});
        test.method1((SAM1<Comparator)n -> {List list = Arrays.asList("string1", "string2"); Collections.sort(list,n);});
        test.method1((SAM1<Thread>)n -> {n.start();});
    }

    interface SAM1<X> {
        void m1(X arg);
    }

    <X> void method1(SAM1 s) {}
}

Other Java examples (source code examples)

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

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

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 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.