Created
March 3, 2019 17:30
-
-
Save johnynek/f4d122aa25e632584a8e74a09c25b182 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class B { } | |
class Main { | |
public static void main(String[] args) { | |
B strMain = Main.<String>cast("this is not a b"); | |
System.out.println(strMain.toString()); | |
} | |
public static <A extends Object> B cast(A a) { | |
B[] ary = new B[1]; | |
put(ary, a); | |
return ary[0]; | |
} | |
public static void put(Object[] ary, Object o) { | |
ary[0] = o; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment