File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Generic methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Generic methods" Watch "Generic methods" New topic
Author

Generic methods

vuthlarhi donald
Ranch Hand

Joined: Jul 31, 2006
Posts: 76



how can I call the methods, to list and addAll
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generic methods