Advertisement
DulcetAirman

generic casting

Dec 19th, 2018
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.26 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement