This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes HashSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "HashSet" Watch "HashSet" New topic


Jayaram Subramanian

Joined: Aug 12, 2008
Posts: 7

The code is not compiling and giving identifier expected. Where am i going wrong?
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 347
The last few statements seems to be floating around. Try putting them in to the main method.

It would also help if you posted the error output..
Vijitha Kumara

Joined: Mar 24, 2008
Posts: 3817

There are few errors in your code.
First the part,

should be inside a normal method or in the main method (not everything in that but as you trying to test your class it's better be in the main method).

Constructor for the SetTest(String) is not defined. Instead you have,

which is considered a normal method, happen to have the class name. It should be


is wrong, since you can't add String to a set which is defined to have objects of SetTest.

[How to ask questions] [Twitter]
I agree. Here's the link:
subject: HashSet
Similar Threads
Generic doubt
Why mutable elements of Sets?
Enthuware mock test question (hashCode)
using Sets
Using Character and Strings with HashSet ,LinkedHashSet,HashMap,LinkedHashMap Problem