• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what's the error?

 
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
Marshal
Pie
Posts: 21423
84
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic