

How to define a List of Integers in Kotlin?.How to add Element to List at Specific Index in Kotlin?.How to access Index of Element while Filtering Kotlin List?.How to Remove specific Element from List in Kotlin?.How to Remove all Elements from a List in Kotlin?.How to Remove All Occurrences of Element from Kotlin List?.How to Iterate over List of Lists in Kotlin?.How to Iterate over Elements of List using For Loop in Kotlin?.How to Filter only Strings from a Kotlin List?.How to Filter only Non-Empty Strings of Kotlin List?.How to Filter only Integers from a Kotlin List?.

How to Filter Odd Numbers of a Kotlin List?.How to Filter List of Strings based on Length in Kotlin?.How to Filter Even Numbers of a Kotlin List?.How to Filter Elements of a List based on Condition in Kotlin?.In this Kotlin Tutorial, we learned how to find the index of a given element in this list, using Kotlin List.indexOf() function. We can use this behavior to check if element is present in the list or not. If the element is present in the list, then list.indexOf(element), will return a non-negative integer, else it returns -1. Output Index of element "de" in the list is 3 Example 2: List.indexOf() to Check if Element is in List Print("Index of element \"$element\" in the list is $index") In this example, we will take a list of strings, and find the index of given string in the list. Example 1: Find Index of First Occurrence of Element in List If in case, the specified element is not contained in the list, then the function would return -1. List.indexOf() function returns the index of the first occurrence of the specified element in the list. The datatype of element should match the datatype of elements in list. The element, whose index to be found in the list. The syntax of List.indexOf() function is list.indexOf(element)
