链接的对象列表! [英] linked List of Objects!
本文介绍了链接的对象列表!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将对象添加到链接列表中.
我有一个名为书"的类.
我使用以下代码将图书对象"添加到链接列表中:
I''m Trying to add Objects to a Linked List.
I Have a Class Named "Books".
I add Books Objects to the linked list using the following Code :
<br />
LinkedList<Books> List = new LinkedList<Books>();
List.add(new Books());
但是,当我尝试获取链接列表的大小时,无论我添加的书有多老,它始终为零"0".
例如:
But When I Try to get the size of my Linked List , it is always Zero "0" no matter how manny Books I Add.
for example :
System.out.println(List.size());
在这里它将输出"0" ...
该怎么办 ??我的代码有什么问题?
________________________________________
请我帮忙..
Here it will output "0"...
What to do ?? what is wrong with my code ?
________________________________________
PLEASE I NEED YOUR HELP ..
推荐答案
在调试器中运行它,以确保add
实际上是,并且名为在List
的同一实例上>>List.size()
之前.几乎不可能是其他东西.
—SA
Run it under debugger to make sure thatadd
is actually called, and called beforeList.size()
on the same instance ofList
. It hardly can be something else.
—SA
这篇关于链接的对象列表!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文