aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes why doesnt this compile? 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 "why doesnt this compile? " Watch "why doesnt this compile? " New topic
Author

why doesnt this compile?

Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531


return type is list..and am returning an arraylist?

this is from inquistion? is it related to <String>
rohan yadav
Ranch Hand

Joined: Oct 13, 2009
Posts: 156
List<> is superclass of ArrayList<>, hence we can return ArrayList<>. So thats why it compiles


Sage of The Monstrous Toad of Mount Myoboku
Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
it doesnt compile.......
rohan yadav
Ranch Hand

Joined: Oct 13, 2009
Posts: 156
may be this will help you

Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
The code does not compile because the expected return type is List<T>, but you are returning List<String>.

You cannot guarantee that List<String> is of type List<T> at compile time, therefore, the compiler generates an error.
Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
Thanks Rohan and Edwin....understood the concept
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why doesnt this compile?