Hi Miga:
I tried the following code instead of the system out print.
// Retrieve an iterator to the hashset:
Iterator iter = hs.iterator();
// Extract elements from iterator. Note that the elements may not
// follow the order in which they are added to HashSet.
while(iter.hasNext())
{
System.out.print(iter.next());
iter.remove();
}
But it does not work!
Respects,
JKid314159
http://existentialists.blogspot.com/
--- On Sun, 8/9/09, miga <[email protected]> wrote:
From: miga <[email protected]>
Subject: [java programming] Re: Lab 1016-1.4
To: "Free Java Programming Online Training Course By Sang Shin"
<[email protected]>
Date: Sunday, August 9, 2009, 5:49 PM
On Aug 9, 11:03 pm, JKid314159 <[email protected]> wrote:
> Dear Java Programmer:
>
>
> I am not too sure I have followed the instructions:
>
> I created the following:
> MyClassObject classObj1 = new MyClassObject("Eleven", 11);
You don't need this
but you need:
myhashset.add(new MyClassObject("Eleven", 11));
Then you need some getters and setters in MyClassObject and to
override the toString method of MyClassObject so that you can get a
user-friendly output when printing the HashSet.
>
>
> then
> System.out.println(hs.add(classObj1));
Use the hashset to display the value:
System.out.println(myHashSet);
>
>
> Instructions say:
> "Display the HashSet object"
>
> I receive result for two objects Obj1 and Obj2 added:
> myhashset.myclassobj...@addbf1,
> myhashset.myclassobj...@19821f
This is the hexadecimal form of the hash code value for this object.
See hashCode and toString method of class Object.
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---