Java 基于哈希的表返回空值

Java 基于哈希的表返回空值,java,guava,Java,Guava,我有一个返回null的函数 输入示例: String alice=table.get(“alice”、“Smith”) 这是我的密码: public void setTab() { table.put("Alice","Smith","Manager"); ... } // get all persons with a surname of Smith final Collection<String> smiths = table.column("Smith").v

我有一个返回null的函数

输入示例:
String alice=table.get(“alice”、“Smith”)

这是我的密码:

public void setTab() {
    table.put("Alice","Smith","Manager");
    ...
}

// get all persons with a surname of Smith
final Collection<String> smiths = table.column("Smith").values();

// get all persons with a firstName of Bob
final Collection<String> bobs = table.row("Bob").values();

// get a specific person
    final String alice=table.get("Alice", "Smith");

public void printSpecial() {
    System.out.println(alice);
    System.out.println(smiths);
    System.out.println(bobs);

}

public void prinTab()  {
    for (Cell<String, String,String> cell: table.cellSet()){
        System.out.println(cell.getRowKey()+" "+cell.getColumnKey()+" "+cell.getValue());
    }
}
public void setTab(){
表.put(“爱丽丝”、“史密斯”、“经理”);
...
}
//获取所有姓史密斯的人
最终集合smiths=表.column(“Smith”).values();
//让所有人都姓鲍勃
最终集合Bob=表.row(“Bob”).values();
//找一个特定的人
最后一个字符串alice=table.get(“alice”,“Smith”);
公共图书馆{
System.out.println(alice);
系统输出打印(史密斯);
系统输出打印项次(bobs);
}
公共无效prinTab(){
对于(单元格:table.cellSet()){
System.out.println(cell.getRowKey()+“”+cell.getColumnKey()+“”+cell.getValue());
}
}
对,它是空的,因为(除非您没有正确复制代码),行

final String alice=table.get("Alice", "Smith");
在实例化类时调用。但是,您的
setTab()
函数大概要到之后的某个时候才会被调用。在调用
setTab()