Java is an object-oriented language. Java has many classes, among which the word index is included in the List class of Java. A friend asked what it means and what it does. Does it have anything to do with indexing?
#There is an index in Java's List class, and the value in the list can be obtained through the index, which is an integer value.
You can return the index of the object in the list through indexOf(object o).
Usage of Indexof in List (determining whether it exists)
string str = "aa"; ArrayList list = new ArrayList(); list.Add("bb"); list.Add("aa"); list.Add("cc"); if (list.IndexOf(str) == -1) { list.Add(str); }
The above is the detailed content of What does index mean in java?. For more information, please follow other related articles on the PHP Chinese website!