gpt4 book ai didi

java - java中访问列表元素

转载 作者:行者123 更新时间:2023-11-30 06:07:08 25 4
gpt4 key购买 nike

我创建了一个链表对象,如下

 importBuffer = new BufferedReader(new FileReader(importcsvFile));
while ((line = importBuffer.readLine()) != null) {

// use comma as separator
String[] importedFile = line.split(cvsSplitBy); //cap,comune,provincia,stato

System.out.println("Codice Azienda " + importedFile[0] + " , Codice Cliente=" + importedFile[1] + " , Regione Sociale=" + importedFile[2] + " , Indrizzo=" + importedFile[3] + " , comune=" + importedFile[4] + " , provincia=" + importedFile[5] + " , stato=" + importedFile[6] +"]");
counter++;
PublicDefinition.importList.add(importBuffer.toString());

List customers = select.select(importedFile[0],importedFile[1], importedFile[3]);

if(!customers.isEmpty())
{

System.out.println("selected Customer : " + customers.size());
buffureList = customers;
Object a=List.class.cast(customers);

PublicDefinition.testingList.add(buffureList.toString());

System.out.println("selected Customer : " + PublicDefinition.importList.get(0));
System.out.println("selected Customer : " + PublicDefinition.testingList.getFirst());

updateCustomer = customers;
if(customers.get(0)==importedFile[0])
System.out.println("Matched Codice Azienda");
select.updateTable(importedFile[1], importedFile[3], "10.34", "11.40"); //String CodiceCliente, String indrizzo, String latitude, String longitute
}
}

当我尝试使用

访问链接列表的元素时
System.out.println("selected Customer  : " + PublicDefinition.importList.get(0));

我得到了输出:

selected Customer  : java.io.BufferedReader@420dc55b

我认为这是内存引用,但我想检索链表的值

我的选择功能是:

public List<Customer> select(String codiceAzienda, String codiceCliente, String indrizzo) {
return jdbcTemplate.query(
"SELECT * FROM customers WHERE CodiceAzienda= ?",
new Object[] { codiceAzienda},
(rs, rowNum) -> new Customer(rs.getLong("id"),
rs.getString("CodiceAzienda"), rs.getString("Indrizzo"), rs.getString("codice_cliente"), rs.getString("Indrizzo")));
}

最佳答案

您添加了 importBuffer 对象toString() 值,而不是实际内容。默认的toString()实现(每个对象都继承自...Object)返回ClassName@HashCode。所以你的输出没有错误,但你的输入是错误的。

参见Object.toString() in the javadoc

关于java - java中访问列表元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42278704/

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