daily pastebin goal
79%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 51 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. Understanding wildcards in Java generics
  2. List<String> a = new ArrayList<String>();
  3. a.add("foo");
  4.  
  5. // b is a List of anything
  6. List<?> b = a;
  7.  
  8. // retrieve the first element
  9. Object c = b.get(0);
  10. // This is legal, because we can guarantee
  11. // that the return type "?" is a subtype of Object
  12.  
  13. // Add an Integer to b.
  14. b.add(new Integer (1));
  15.    
  16. Object c = b.get(0);
  17.    
  18. public Foo findAFooThatILike(Collection<? extends Foo> foos);
  19.    
  20. public Foo findAFooThatILike(Collection<Foo> foos);
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
 
Top