【问题标题】:ArrayList does not give the get option to retrieve the data [closed]ArrayList 不提供获取数据的获取选项[关闭]
【发布时间】:2014-04-28 09:10:06
【问题描述】:

我从现有的客户和计算机类创建客户和计算机数组列表,如下所示

ArrayList<Customer> customer = new ArrayList<Customer>();

ArrayList<Computer> computer = new ArrayList<Computer>();

但我无法获得检索数据的选项。谁能解决这个问题?

【问题讨论】:

  • But I don't available to get option to retrieve the data我不知道你在问什么。
  • 说真的,请先阅读arrayList documentation
  • 我的意思是我无法检索 arrey 列表中的项目,因为它不给我 get(customer.get(index))
  • 最好使用 List=new ArrayList

标签: java arraylist


【解决方案1】:

customer.get(i)i 是索引。

computer.get(i) 

你已经这样了。

【讨论】:

  • 是的。但我没有得到创建的数组列表的选项
【解决方案2】:

使用此处指定的此方法。请阅读这些内容! http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html

get(int 索引) 返回此列表中指定位置的元素。

【讨论】:

    【解决方案3】:

    对于客户: Customer ithCustomer = customer.get(i);(retrieve ith item in the customer list)

    【讨论】:

      猜你喜欢
      • 2022-01-02
      • 2014-04-04
      • 1970-01-01
      • 2021-01-14
      • 1970-01-01
      • 2017-07-07
      • 1970-01-01
      • 1970-01-01
      • 2020-01-30
      相关资源
      最近更新 更多