OnJava8-Examples/generics/SelfBoundingMethods.java
2020-10-07 13:35:40 -06:00

14 lines
390 B
Java

// generics/SelfBoundingMethods.java
// (c)2020 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
public class SelfBoundingMethods {
static <T extends SelfBounded<T>> T f(T arg) {
return arg.set(arg).get();
}
public static void main(String[] args) {
A a = f(new A());
}
}