cześć, jak w temacie.Potrzebuje wyciągnąć z mapy:
Map<Long, UserMaker> userMakerTest = new HashMap<>();
Utworzony i dodany do kolekcji obiekt np:
userMakerTest.put((long) 1, new UserMaker(1,"Jan", "Nowak", 12345,0));
userMakerTest.put((long) 2, new UserMaker(2,"Janusz", "Kowal", 543321, 0));
Po zmiennej id danego obiektu:
System.out.println(userMakerTest.get(1));
Ale dostaje false jednak tam są obiekty bo sprawdzałem po:
System.out.println(userMakerTest.isEmpty());
Jeszcze klasa UserMaker:
package project.emil.lib.model;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class UserMaker {
private long id;
private String name;
private String surname;
private int NIN;
private int whatIhave;
public UserMaker() {
}
public UserMaker(long id, String name, String surname, int NIN, int whatIhave) {
this.id = id;
this.name = name;
this.surname = surname;
this.NIN = NIN;
this.whatIhave = whatIhave;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public int getNin() {
return NIN;
}
public void setNin(int NIN) {
this.NIN = NIN;
}
public void setWhatIhave(int whatIhave) {
this.whatIhave = whatIhave;
}
public int getWhatIhave() {
return whatIhave;
}
public String toString() {
return "UserMaker [id=" + id + ", name=" + name + ", surname=" + surname + ", NIN=" + NIN + ", whatIhave="
+ whatIhave + "]";
}
}
Czy taki zabieg jest ogólnie możliwy? :)