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

Java example source code file (T6939780.java)

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

foo, foo2, number, t6939780

The T6939780.java Java example source code

/*
 * @test /nodynamiccopyright/
 * @bug 6939780 7020044 8009459 8021338
 *
 * @summary  add a warning to detect diamond sites
 * @author mcimadamore
 * @compile/ref=T6939780_7.out -Xlint:-options -source 7 T6939780.java -XDrawDiagnostics -XDfindDiamond
 * @compile/ref=T6939780_8.out T6939780.java -XDrawDiagnostics -XDfindDiamond
 *
 */

class T6939780 {

    static class Foo<X extends Number> {
        Foo() {}
        Foo(X x) {}
    }

    void testAssign() {
        Foo<Number> f1 = new Foo(1);
        Foo<?> f2 = new Foo();
        Foo<?> f3 = new Foo();
        Foo<Number> f4 = new Foo(1) {};
        Foo<?> f5 = new Foo() {};
        Foo<?> f6 = new Foo() {};
    }

    void testMethod() {
        gn(new Foo<Number>(1));
        gw(new Foo<Number>());
        gw(new Foo<Integer>());
        gn(new Foo<Number>(1) {});
        gw(new Foo<Number>() {});
        gw(new Foo<Integer>() {});
    }

    void gw(Foo<?> fw) { }
    void gn(Foo<Number> fn) { }

    static class Foo2<X> {
        X copy(X t) {
            return t;
        }
    }

    void testReciever() {
        Number s = new Foo2<Number>().copy(0);
    }

}

Other Java examples (source code examples)

Here is a short list of links related to this Java T6939780.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.