クラスのオブジェクトのハッシュマップを作成したいと思います。私は文字列としてハッシュマップ持つキーを作成し、ハッシュマップに値を挿入しようとしていますクラスのオブジェクトのハッシュマップを作成する
public class BitbucketRecordDataModel {
private String softwareId;
private String scmUrl;
private String aggregationDate;
public BitbucketRecordDataModel(String softwareId, String scmUrl, String aggregationDate) {
this.softwareId = softwareId;
this.scmUrl = scmUrl;
this.aggregationDate = aggregationDate;
}
public String getSoftwareId() {
return softwareId;
}
public void setSoftwareId(String softwareId) {
this.softwareId = softwareId;
}
public String getScmUrl() {
return scmUrl;
}
public void setScmUrl(String scmUrl) {
this.scmUrl = scmUrl;
}
public String getAggregationDate() {
return aggregationDate;
}
public void setAggregationDate(String aggregationDate) {
this.aggregationDate = aggregationDate;
}
}
- 次のように
クラスです。しかし、私はハッシュマップの詳細を取得しようとすると、私はnullと私のクラスの名前であるいくつかの非常に奇妙な値を取得します。
HashMap<String, BitbucketRecordDataModel> map = new HashMap<String, BitbucketRecordDataModel>();
cacheCondition = "hi";
username = "hi1";
protocol = "hi2";
BitbucketRecordDataModel bitbucketRecordDataModel = new BitbucketRecordDataModel(cacheCondition, username, protocol);
map.put(repoName, bitbucketRecordDataModel);
System.out.println(map.get("deployment-service-api.git"));
私はJavaとハッシュマップの新機能です。私は何が間違っているのですか、なぜそのような奇妙な価値を得ていますか?
'map.get(repoNameを)やってみてください。私のclass'の名前です –
'いくつかの非常に奇妙な値 'と結果を確認 - あなたがしたい場合は、'あなたは 'のtoStringを(上書きする必要があります)奇妙な値を取得しないでください。 – Eran
@エラン、ちょっと魅力的だったよ。どうもありがとうございます –