SHARE
TWEET

generic casting

DulcetAirman Dec 19th, 2018 (edited) 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package quiz.generics;
  2.  
  3. public class SomeClass {
  4.     static <T> T cast(Object object) {
  5.         return (T) object;
  6.     }
  7.     public static <Integer> void main(String[] args) {
  8.         String str = "123";
  9.         Integer i = SomeClass.<Integer>cast(str);      
  10.         System.out.println(i);
  11.     }
  12. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top