• Post Reply Bookmark Topic Watch Topic
  • New Topic

Generic methods

 
vuthlarhi donald
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



how can I call the methods, to list and addAll
 
Rob Spoor
Sheriff
Posts: 20831
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
U is Integer, so:

Although you might want to change one of the wildcards.


public static <U> void addAll(List<U>list, U...array)

You can modify this to have a List<? super U>. That way, you can use a List<Object> as well. Since the list stores U or a superclass of U, it is safe to add the array elements.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!