【问题标题】:how to set objeck hashmap on java如何在java上设置对象hashmap
【发布时间】:2017-03-16 18:58:18
【问题描述】:

我有一个像这样的模型“句子”:

String kalimat;
HashMap<String, Double> bobotChiSquare = new HashMap<>();
HashMap<String, Double> bobotTFIDF = new HashMap<>();
HashMap<String, Integer> countTandaBaca = new HashMap<>();
public HashMap<String, Double> getBobotChiSquare() {
    return bobotChiSquare;
}

public void setBobotChiSquare(HashMap<String, Double> bobotChiSquare) {
    this.bobotChiSquare = bobotChiSquare;
}

我想像这样在对象“句子”上设置值哈希图:

ArrayList <Sentence> listToken = new ArrayList<>();
     Sentence sentence = null;
     for (int i = 0; i < input.size(); i++) {
         sentence.setKalimat(input.get(i));
         String[] token = input.get(i).split(" ");
         for (int j = 0; j < token.length; j++) {
             sentence.setBobotChiSquare(token[j] , new Double(0,0));
         }
     }

但我在一行中有错误

sentence.setBobotChiSquare(token[j] , new Double(0,0));

谁能帮忙?

【问题讨论】:

    标签: java object hashmap setvalue


    【解决方案1】:

    您的方法需要 HashMap 作为参数,但您传递了 Stringdouble。您首先必须将它们放入HashMap

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-03
      • 2017-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多