gpt4 book ai didi

Java hashmap int 不能被取消引用

转载 作者:行者123 更新时间:2023-11-29 05:23:44 25 4
gpt4 key购买 nike

我想将数据库中的一些数据分配给 Netbeans 中的 jTable。问题是在 get 方法的主窗体中,客户列被命名为:

  public int getCustomeridCustomer() {
return customeridCustomer;
}

所以我在构建数据访问对象的表单中使用了相同的名称。

Object[] objects = new Object[3];
if(l.size() > 0)
{
for(int i = 0; i < l.size();i++)
{
Rentals hashmap = l.get(i);
objects[0]=hashmap.getIdRentals().toString();
objects[1]=hashmap.getCustomeridCustomer().toString();
objects[2]=hashmap.getRentedDate().toString();
amod.addRow(objects);
}
this.jTable1.setModel(amod);

但是! Netbans 说“不能取消引用 int”。任何帮助将不胜感激。

最佳答案

在这一行

objects[1]=hashmap.getCustomeridCustomer().toString();

您正在尝试调用基本类型的方法。在 Java 中,您只能调用类和对象的方法,而不能调用原始类型。

那是因为方法 public int getCustomeridCustomer() 返回一个 int,这是一个原始类型。

关于Java hashmap int 不能被取消引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23584312/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com