Home  >  Article  >  Java  >  What does index mean in java?

What does index mean in java?

little bottle
little bottleOriginal
2019-05-22 13:36:5221305browse

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?

What does index mean in java?

#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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn