File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes what's the error? 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 "what Watch "what New topic

what's the error?

Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
I am getting error with this simple problem which is supposed to compile with out any problem.

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

The future belongs to those who believe in the beauty of their dreams.Dream BIG!
Henry Wong

Joined: Sep 28, 2004
Posts: 20517

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.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
Thanks alot!
I agree. Here's the link:
subject: what's the error?
It's not a secret anymore!