【发布时间】:2015-05-27 19:36:25
【问题描述】:
我有对象 Song 的 ArrayList。每个Song 都有自己的参数title, composer, duration,。我正在尝试编写将查找title 的object Song 的方法,并将使用此参数为我提供ArrayList 中对象的INDEX。
songs 是 ArrayList 的名称
public int findSong(String title) {
int index = songs.indexOf(title);
System.out.println(index);
return index;
}
在这种情况下,方法正在寻找名称为help 的对象,但是如何编写他将寻找具有等于@987654332 的参数title 的对象的index 的方法@。我只是想了解其中的逻辑)
classname.findSong("help");
【问题讨论】:
标签: java arraylist collections indexof