Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

import java.util.* ?!!

 
soumya ravindranath
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I just noticed this unexpected behaviour on my system. If I have

compilation fails with 'cannot resolve symbol' error for HashSet constructor. It even said -

TestHashSet.java:27: incompatible types
found : HashSet
required: java.util.Set
Set s = new HashSet();
^
TestHashSet.java:28: cannot resolve symbol
symbol : constructor HashSet (java.util.Set)
location: class HashSet
Set hash = new HashSet(s);


Compilation succeeds only if I do individual imports for Set and HashSet ( I tried for ArrayList, List, Collection too ).

What am I missing ?!

thanks,
Soumya.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Works fine for me. I'd double check your import statement.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have defined your own class named "HashSet", and it's on your class path. Even if you've deleted the source code, the .class file is hiding somewhere. Find it, and delete it.
 
soumya ravindranath
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and you are God!

( I did have it from some previous experiment )
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just recognized this symptom from helping other people in the past. This happens to people more often than you would think! Glad I could help.
 
jin sun
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
haha yea that happens to me a lot.
 
Timmy Marks
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once again, someone is bitten by using the default package!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic