-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
  • 16,432
  • 7
  • 31
  • 51
Mohsen_Fatemi
  • 2,221
  • 2
  • 15
  • 24