I have created 2 classes [Banking and Website] In banking class I have created Getters and setters for username and password data In Website class I have created LinkedHashMap to get the output. But when I run/compile the program i get the output in Memory codes. Please help me on this issue.
Code for Class Banking :
package org.encap;
public class Banking {
private int username;
private String password;
public int getUsername() {
return username;
}
public void setUsername(int username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
Code for Class Website :
package org.encap;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.List;
import java.util.Set;
public class Website {
public static void main(String[] args) {
Banking a=new Banking();
a.setUsername(111);
a.setPassword("Password");
//System.out.println(a.getUsername());
//System.out.println(a.getPassword());
Banking b=new Banking();
b.setPassword("Password2");
b.setUsername(222);
//System.out.println(b.getUsername());
//System.out.println(b.getPassword());
//user defined Map
Map<Integer, Banking> mp=new LinkedHashMap<>();
mp.put(1, a);
mp.put(2, b);
System.out.println(mp.get(1));
System.out.println(mp.get(2));
System.out.println(mp.values());
System.out.println(mp.entrySet());
}
}
Output when I run the program :
org.encap.Banking@7852e922
org.encap.Banking@4e25154f
[org.encap.Banking@7852e922, org.encap.Banking@4e25154f]
[1=org.encap.Banking@7852e922, 2=org.encap.Banking@4e25154f]
I am not getting the output in String and Numbers .. Im getting only memory vales.