Results 1 to 3 of 3
Thread: bluej hashset problem ;s
- 12-03-2010, 08:42 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 22
- Rep Power
- 0
bluej hashset problem ;s
alright, i'm stuck on this part of my project and i really tried to get over it but nothing seems to get better...
My aim is to add a number of objects to a HashSet with a for-loop but i can't seem to accomplish that. The size of the HashSet stubbornly stays null. Here is the code:
/**
* Constructor for objects of class Pocket
*/
public Pocket()
{
// initialise instance variables
HashSet<Object> Object = new HashSet<Object>();
for(int i=0; i<20; i++) {
Object.add(new Object());
}
I might be missing something crucial here and call me a retard but i really cant see what it is so any help would be appreciated.
Thanks in advance :)
- 12-06-2010, 09:54 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
How are you checking the size of the hash set?
Oh, and Object is not a good name for a variable. Variables should start with a lower case so you don't end up with variables being the same name as classes.
- 12-07-2010, 05:56 PM #3
Member
- Join Date
- Dec 2010
- Posts
- 22
- Rep Power
- 0
Similar Threads
-
:( anyone here plz help on HashSet
By waklo99 in forum New To JavaReplies: 8Last Post: 09-20-2010, 03:02 AM -
Hashset and Custom Objects problem! Wont add! :(
By maz09 in forum New To JavaReplies: 4Last Post: 03-20-2010, 03:22 AM -
HashSet Contains problem
By guywalder in forum Advanced JavaReplies: 11Last Post: 09-01-2009, 02:48 PM -
HashSet anomaly
By jon80 in forum New To JavaReplies: 1Last Post: 06-21-2009, 08:22 PM -
Iterating through a HashSet
By Java Tip in forum Java TipReplies: 0Last Post: 01-21-2008, 04:34 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks