Created
November 8, 2017 15:45
-
-
Save rac021/a246dd60a89eac2da611623cca7bc6d3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| package entypoint; | |
| /** | |
| * | |
| * @author ryahiaoui | |
| */ | |
| public class TGenericTest { | |
| public static void main(String[] args) { | |
| Integer callMe = callMe( 10, Integer.class ) ; | |
| System.out.println(" --> " + callMe) ; | |
| Boolean bool = callMe( true, Boolean.class ) ; | |
| System.out.println(" --> " + bool) ; | |
| } | |
| public static <T> T callMe( T t ,Class<T> clazz ) { | |
| return clazz.cast(t) ; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment