V
Vijay
hi all,
What do I need to do in order to make the following code work.
I expect the output to be "K1 value", but it returns me null.
Map m = new HashMap();
Key k1 = new Key("h","u");
Key k2 = new Key("h","u");
m.put(k1,"K1 value");
System.out.println(m.get(k2));
The Key class is
public class Key {
private String host;
private String user;
public Key(String h, String u) {
host = h;
user = u;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
}
What do I need to do in order to make the following code work.
I expect the output to be "K1 value", but it returns me null.
Map m = new HashMap();
Key k1 = new Key("h","u");
Key k2 = new Key("h","u");
m.put(k1,"K1 value");
System.out.println(m.get(k2));
The Key class is
public class Key {
private String host;
private String user;
public Key(String h, String u) {
host = h;
user = u;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
}