Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

what's the error?  RSS feed

 
Nabila Mohammad
Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting error with this simple problem which is supposed to compile with out any problem.

I get:
incompatible types
found:TreeSet
required java.util.Set
Set s=new TreeSet();
^

 
Henry Wong
author
Sheriff
Posts: 22841
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically, you named your class TreeSet. So, when you instantiated a TreeSet, it will instantiate your class, and not the TreeSet in the collection classes.

And since your TreeSet doesn't implement the Set interface, you are getting the error.

Henry
 
Nabila Mohammad
Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks alot!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!