aspose 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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 19541
    
  16

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
 
Similar Threads
add(index,object) and reverseOrder()
Boxing with Arrays.asList()
Observing non Observable
Subdividing a Collection into smaller collections
Generics and a copy method