-1

In Java is there a method to find index of a particular string in ArrayList?
For Example if cities is an array list of 100 cities and I want to find the index of "New York".

Auto
  • 1
  • 3

1 Answers1

0

You can use the indexOf(...) method for search in ArrayList. If the String exists within the ArrayList, it returns the index of the String, otherwise it returns -1.

This link might be helpful.

Turing85
  • 18,217
  • 7
  • 33
  • 58
Mohsen_Fatemi
  • 2,183
  • 2
  • 16
  • 25