Hey Brain,
MyOwnClass is a class where you assigned values to variables
by creating object. but you dint implement the toString() method to return
specific values in that class, toString() of object class should be
overriden into MyOwnClass to return values.
Integer class has already implemented toString(), so when you
call object reference of integer object it will return values which are
passed on while creating intege.
..
you can check more info in the below link.............
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Integer.html#Integer(int)<http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Integer.html#Integer%28int%29>
I hope you got point where you did wrong.
Thanks
srinvas
On Sat, Nov 15, 2008 at 8:45 PM, Agung Prasetyo <[EMAIL PROTECTED]>wrote:
> Hi, the java master, i have the class like this :
> public class MyOwnClass
> {
> String name;
> int age;
>
> public MyOwnClass(String name,int age)
> {
> this.name = name;
> this.age = age;
> }
> }
>
> And i add this class instance object to the HashSet object --> s
> s.add(new MyOwnClass("Paris",19));
>
> when the s object is print using iterator, why the output show like this :
> [EMAIL PROTECTED]
>
> please help me ! i'm very confuse the following code.
> why when i add the object Integer ex : s.add(new Integer(8));
> why the output is 8
> Thanks very much.
>
> >
>
--
Thanks & Regards
Srinivas
(214-597-0697)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---