简体   繁体   中英

how to search in a list in java?

i have three list containing 3/4 items in each. Now a node contains each those items. when the node is assigned to a particular item it has to search for that item in those list and should return the particular list containing that item. How can i do this?

Try this : In case the

if(listOne.contains(object))
            return listOne;

The list.contains() uses equals. so, if list.contains() does not give you the expected result, you should be overriding the equals method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM