-1
In the store variable when trying to add a new element of type "Store" it always stays with only one element and does not add a new element. And never add a new one. Follow the codes: Metodo main:
public static void main(String[] args) {
Usuario usuario = new Usuario();
Set<Integer> idsLojas = new HashSet<>();
idsLojas.add(123);
idsLojas.add(333);
idsLojas.add(3333);
Set<Loja> lojas = new HashSet<>();
for (Integer idLoja : idsLojas) {
lojas.add(new Loja(idLoja));
}
usuario.setLojas(lojas);
System.out.println(usuario.getLojas().size());
}
Shop builder:
public Loja(Integer id) {
this.setId(id);
}
The result is always 1, even if I add 3 values.
And the local variable
lojas
, has only one element?– Jefferson Quesado