でキーとして、私はこのクラスを持っている:は、ハッシュマップ
public class Offer {
private Integer id;
private String description;
private Double price;
private String currency;
private Date timeExpired;
public Offer(Integer id, String description, Double price, String currency, Date timeExpired){
this.id = id;
this.description = description;
this.price = price;
this.currency = currency;
this.timeExpired = timeExpired;
}
}
私はOffer
としてクラスOffer
と値のIDを参照キーでハッシュマップを作成したいです。
HashMap<id of Offer(?),Offer> repo = new HashMap<id of Offer(?),Offer>();
どうすればいいですか?
それぞれOffer
のIDをキーとして割り当て、Offer
のオブジェクトをHashmap repoの値として割り当てる方法を教えてください。 idはHashMap<Integer, Offer>
Integer
あなたの必要性ですので、私は、メソッドrepo.put
'のHashMap <整数、オファー>'が悪いのか? –
'HashMap' –
Oleg
'Repo.put(offer.getId()、offer)' – Oleg