Search elements in ArrayList in Java

In this tutorial, we will learn how to Search Elements in ArrayList in Java.

ArrayList in Java is a resizable-array implementation of the List interface. ArrayList in Java implements all optional list operations, and permits all elements, including null. In addition to implementing the List interface, this class provides methods to manipulate the size of the array that is used internally to store the list. ArrayList class in Java provides two methods indexOf() and lastIndexOf().

We will use indexOf() and lastIndexOf() methods to search elements in ArrayList in Java. The syntax of indexOf() and lastIndexOf() methods are:

Syntax of indexOf() method:

this method returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.

Syntax of lastIndexOf() method:

this method returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.

Example:

Output:

 

Related posts

0 Thoughts to “Search elements in ArrayList in Java”

  1. Your comment is awaiting moderation.

    Wow many of amazing advice!
    http://canadianpharmacysilo.com/
    no prescription online pharmacy
    northwestpharmacy
    top rated canadian pharmacies online
    canadian viagra

  2. Your comment is awaiting moderation.

    You explained this fantastically!
    http://canadianpharmaciescubarx.com/
    canadian pharcharmy online
    london drugs canada
    online drugstore
    canada pharmacy

  3. Your comment is awaiting moderation.

    Fantastic postings. Thank you.
    http://canadianonlinepharmacynnm.com/
    best online canadian pharcharmy
    canadian pharmacy
    canada pharmacy no prescription
    canadian pharmacies

  4. Your comment is awaiting moderation.

    You said it perfectly.!
    http://canadianpharmacymim.com/
    canada drug prices
    canadian pharmacies-24h
    canadian online pharmacy
    canadian pharmacies online

  5. Your comment is awaiting moderation.

    Many thanks! Ample info!

    http://canadianpharmacymim.com/
    discount pharmacy
    canada pharmaceuticals online
    best canadian pharmacies
    canadian pharmacies-24h

  6. Your comment is awaiting moderation.

    You’ve made your stand quite effectively!!
    https://nicktambone.com/
    canada pharmacies online prescriptions
    canada pharmacy
    canadian pharmacies that are legit
    canada pharmaceutical online ordering

  7. Your comment is awaiting moderation.

    Reliable material. Appreciate it.
    http://canadianonlinepharmacynnm.com/
    prescription online
    canadian online pharmacies
    walgreens pharmacy
    canada drugs

  8. Your comment is awaiting moderation.

    Regards, Helpful information!
    http://talahicc.com/
    cheap drugs online
    canadian online pharmacies
    costco pharmacy pricing
    canadian pharmaceuticals online

  9. Your comment is awaiting moderation.

    Whoa a good deal of terrific info.
    http://canadianonlinepharmacynnm.com/
    mexican pharmacies
    global pharmacy canada
    no prescription online pharmacy
    canadian viagra

  10. Your comment is awaiting moderation.

    Thank you, An abundance of postings!

    http://www.canadianpharmacymsn.com/
    online pharmacies
    online pharmacies canada
    canadian drug
    canadian pharmacy online

  11. Your comment is awaiting moderation.

    Cheers! Lots of write ups!

    http://www.canadianpharmacymsn.com/
    drugs without prescription
    canadian online pharmacies
    best canadian online pharmacy
    canadian pharmacies without an rx

  12. Your comment is awaiting moderation.

    Many thanks. A lot of info.

    http://canadianpharmaciescubarx.com/
    buy prescription drugs online
    canada drugs online
    online prescription drugs
    canadian online pharmacy

  13. Your comment is awaiting moderation.

    Truly all kinds of great advice.
    http://canadianpharmacyntx.com/
    best online canadian pharcharmy
    canadian pharmacies without an rx
    safeway pharmacy
    aarp approved canadian online pharmacies

  14. Your comment is awaiting moderation.

    Thanks a lot, A good amount of content!

    http://canadianpharmaciescubarx.com/
    online drugs
    canada pharmacy
    best canadian pharmacies
    canadian pharcharmy

  15. Your comment is awaiting moderation.

    Wow quite a lot of valuable information.
    http://talahicc.com/
    prescription prices comparison
    northwest pharmacy
    canadian online pharmacies
    canada drugs

  16. Your comment is awaiting moderation.

    Nicely put. Cheers!
    https://nicktambone.com/
    top rated online canadian pharmacies
    canadianpharmacy
    canada pharmacies without script
    canada online pharmacies

  17. Your comment is awaiting moderation.

    Thanks, Quite a lot of tips!

    http://canadianonlinepharmacynnm.com/
    buy prescription drugs canada
    canada pharmacy
    best non prescription online pharmacies
    aarp approved canadian online pharmacies

  18. Your comment is awaiting moderation.

    Regards, An abundance of data!

    http://canadianpharmacymim.com/
    canada drug pharmacy
    canada drugs
    canada online pharmacy
    canada drugs online

  19. Your comment is awaiting moderation.

    Thanks a lot, Wonderful information!
    http://talahicc.com/
    compare rx prices
    canadian pharmacies that ship to us
    international pharmacy
    canadian pharmacies without an rx

  20. Your comment is awaiting moderation.

    Many thanks, Plenty of posts.

    http://canadianpharmaciescubarx.com/
    canadian pharmacy 365
    online pharmacies of canada
    canada drugs online pharmacy
    top rated canadian pharmacies online

  21. Your comment is awaiting moderation.

    Cheers. Valuable information!
    http://canadianpharmaciesnnm.com/
    buy prescription drugs without doctor
    canada drug
    online canadian pharmacies
    online pharmacies of canada

  22. Your comment is awaiting moderation.

    Awesome info, Appreciate it.
    http://talahicc.com/
    cheap prescription drugs online
    northwest pharmacy
    canadian drug stores online
    canadian online pharmacies

  23. Your comment is awaiting moderation.

    Nicely put, With thanks!
    http://canadianpharmaciesnnm.com/
    pain meds online without doctor prescription
    trust pharmacy canada
    canadian drugstore
    canada drugs online

  24. Your comment is awaiting moderation.

    You suggested it well!
    http://talahicc.com/
    canadian pharmacies that ship to us
    canada online pharmacies
    prescription drugs online without
    global pharmacy canada

  25. Your comment is awaiting moderation.

    Seriously tons of beneficial facts!
    http://www.canadianpharmacymsn.com/
    drug stores near me
    canadian pharmacies
    canada drugs
    aarp approved canadian online pharmacies

  26. Your comment is awaiting moderation.

    Amazing loads of valuable data!
    http://canadianpharmaciesnnm.com/
    canada pharmacies online
    canadian pharmacies
    canadian pharmacies top best
    canadian viagra

  27. Your comment is awaiting moderation.

    This is nicely put. !
    https://nicktambone.com/
    international pharmacy
    top rated canadian pharmacies online
    canadian pharmacies online
    online pharmacies of canada

  28. Your comment is awaiting moderation.

    Amazing information. Regards.
    http://canadianpharmaciesnnm.com/
    canadadrugs.com pharmacy
    canadian pharmacy online
    canadian drug stores online
    canadianpharmacy

  29. Your comment is awaiting moderation.

    You mentioned that effectively.
    http://talahicc.com/
    drugstore online
    canadian cialis
    pharmacy price compare
    canadian online pharmacy

  30. Your comment is awaiting moderation.

    Terrific material. Thank you.
    http://canadianpharmacyntx.com/
    prescription cost comparison
    canada pharmaceutical online ordering
    approved canadian pharmacies online
    canadian pharmaceuticals online

  31. Your comment is awaiting moderation.

    Terrific info. Regards.
    https://nicktambone.com/
    buy drugs online
    mexican pharmacies shipping to usa
    cheap prescription drugs online
    canadian pharmaceuticals online

  32. Your comment is awaiting moderation.

    You actually reported it effectively.
    http://canadianpharmacyntx.com/
    online pharmacy canada
    canadian pharmacy online
    canadian pharmacy online canada
    canadian pharmacies-24h

  33. Your comment is awaiting moderation.

    You actually said it superbly!
    http://canadianpharmacymim.com/
    online pharmacies no prescription
    canadian pharmacies
    discount pharmacy online
    mexican pharmacies shipping to usa

  34. Your comment is awaiting moderation.

    You explained it superbly.
    http://canadianpharmaciesnnm.com/
    drug costs
    global pharmacy canada
    prescription drugs online without
    canadian viagra

  35. Your comment is awaiting moderation.

    Effectively spoken indeed. !
    http://canadianpharmacysilo.com/
    canadian drug store
    canadian pharmacies-24h
    king pharmacy
    canadian online pharmacies

  36. Your comment is awaiting moderation.

    Appreciate it! A good amount of data!

    http://canadianpharmaciesnnm.com/
    trust pharmacy canada
    trust pharmacy canada
    online pharmacies no prescription
    canada pharmacy online

  37. Your comment is awaiting moderation.

    Amazing data. With thanks!
    http://canadianpharmaciesnnm.com/
    prescription drugs without prior prescription
    top rated canadian pharmacies online
    best online pharmacies no prescription
    trust pharmacy canada

  38. Your comment is awaiting moderation.

    Well voiced certainly! !
    http://www.canadianpharmacymsn.com
    safeway pharmacy
    canadian pharmacies that ship to us
    online drugs
    canada drugs

  39. Your comment is awaiting moderation.

    Thank you, Lots of information!

    http://talahicc.com
    best canadian pharmacies
    canadian viagra
    canadian drug stores online
    london drugs canada

Leave a Comment