File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Generics question from K&B self test Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Generics question from K&B self test" Watch "Generics question from K&B self test" New topic
Author

Generics question from K&B self test

madhu v pe
Ranch Hand

Joined: Apr 21, 2007
Posts: 100
Hi,

I am having a doubt in the answer given for this question.


Please have a look into the Bolde text in the answer
my question is the return type cannot be ArrayList?

Please anyone can help me in explaining this?

Thanks in advance
Abdullah Mamun
Ranch Hand

Joined: Mar 19, 2007
Posts: 99

public static <E extends Number> List<E> process(List<E> nums)
A programmer wants to use this method like this:
// INSERT DECLARATIONS HERE
output = process(input);


The method process() returns a List<E> and it will be assigned to output variable. So if output is declared as an ArrayList then you cannot assign the returned value of process() into it, since List cannot be assigned to ArrayList.

Hope you got the point


MooN
madhu v pe
Ranch Hand

Joined: Apr 21, 2007
Posts: 100
Oh its simple thanks Moon
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generics question from K&B self test