有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Guava的HashBasedTable单元集()

我有以下设置

Table<Integer, Integer, Float> store = HashBasedTable.create();

int i = 0, j = 0;

for (List<String> stack_i : stacks) {
  j = 0;

  for (String entry_j : stack_i) {
    Float alpha = doSomeMagic(entry_j, token);
    if (alpha != null)
      store.put(i, j, alpha);
    j++;
  }
  i++;
}

if (store.cellSet().size() > 0) {
  for (Table.Cell<Integer, Integer, Float> cell : store.cellSet()) {
    if (cell.getValue() > max) {
      max = cell.getValue();
      maxchainIndex = cell.getRowKey();
    }
  }
}

我遇到的问题是出现以下JVM错误:

SEVERE: java.lang.IllegalAccessError: tried to access method com.google.common.collect.Iterators.emptyModifiableIterator()Ljava/util/Iterator; from class com.google.common.collect.StandardTable$CellIterator at com.google.common.collect.StandardTable$CellIterator.(StandardTable.java:310) at com.google.common.collect.StandardTable$CellIterator.(StandardTable.java:306) at com.google.common.collect.StandardTable$CellSet.iterator(StandardTable.java:280)

错误发生在第行

for(Table.Cell<Integer,Integer,Float> cell:store.cellSet())

我看不出我做错了什么。我查过了,商店里至少有一件商品


共 (1) 个答案

  1. # 1 楼答案

    看起来不错,我可以成功运行以下程序。您能在不使用任何附加元素的情况下运行它来消除与for循环无关的任何有趣的业务吗

    Table<Integer, Integer, Double> abc = HashBasedTable.create();
    abc.put(1, 1, 10d);
    for (Table.Cell<Integer, Integer, Double> x : abc.cellSet()) {
        System.out.println(x.toString());
    }