This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generics compilation error

 
Amit K K Amit
Greenhorn
Posts: 8
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,
I am trying to compile the follwing code, can anyone tell me what is the issue in the code?



Compilation Error Message :-
=====================

dotestgenericswithpoly(java.util.List<? extends Animal>) in TestGenerics cannot
be applied to (Cat)
dotestgenericswithpoly(new Cat());

[Edit - added code tags - see UseCodeTags]
 
Matthew Brown
Bartender
Posts: 4549
8
Java Netbeans IDE Scala
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not the generics that are the problem - that wouldn't work in a non-generic version. The problem is that you're passing a Cat to a method that's expecting a List.
 
Amit K K Amit
Greenhorn
Posts: 8
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never write code when you are tired. :-)

That was a silly mistake. Thanks Matthew
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic