我有一个包含聊天消息(List<Chat>
)的列表。
列表包含message, senderID and sentTime
。它看起来如下:
我正在尝试找到消息等于"Do you confirm that you received..."
的索引
我尝试使用chats.indexOf("Do you confirm that you received...")
但是,我一直收到-1
。
我做错了什么?具体来说,如果在该聊天中有多条消息等于"Do you confirm that you received..."
,我想找到最后一个索引。
谢谢
[chats.indexOf("Do you confirm that you received...")
不起作用,因为您要在chats.message
中查找并将其与所需值进行比较。