Hashmap question!

Hello,

please help me in the following issue.

I have created a custom type:

publicinterface UserType{

public UserTypeImpl getUserType(String Number);

}

and:

import java.io.Serializable;

publicclass UserTypeImplimplements Serializable{

private String Number;

private String name;

private String email;

public UserTypeImpl(){}

public UserTypeImpl(String Number, String name, String email){

this.Number = Number;

this.name = name;

this.email = email;

}

and the getters and setter for Number, name and email.

Now, I fill this up with data, and put it into a hashmap:

HM.put(1, uT);//where uT is my type

The problem is, that how can I get the email, name and email from this hashmap?

I always get result like UserTypeImpl@130c19b

thanks in advance,

nagybaly

[1520 byte] By [o9ipa] at [2007-11-26 17:36:28]
# 1
Hi,You should get the object from the map, and then call the getters on the object.You get UserTypeImpl@130c19b when you print the object because you haven't overridden the toString method.Kaj
kajbja at 2007-7-9 0:04:32 > top of Java-index,Java Essentials,Java Programming...
# 2

UserTypeImpl obj = (UserTypeImpl)HM.get(key);

obj.getNumber();

obj.getName();

obj.getEmail();

Since you said you have getter and setter you are suppose to get those values, unless you are printing the object in which case you need

to override the toString() method.

lupansanseia at 2007-7-9 0:04:32 > top of Java-index,Java Essentials,Java Programming...
# 3
Thank you for all of your fast answer!regards,nagybaly
o9ipa at 2007-7-9 0:04:32 > top of Java-index,Java Essentials,Java Programming...