Java string indexOf() is an inbuilt method that returns the index of given character value or substring. If it is not found, then it returns -1. The index counter starts from zero. The indexOf method is used to get the integer value of a particular index of String type object, based on criteria specified in the parameters of the IndexOf method.

Java String indexOf()

A common scenario can be when a system admin wants to find the index of the ‘@’ character of the email Id of a client and then wants to get the remaining substring. In that situation, the IndexOf method can be used.

#java #java indexof

Java String indexOf() Example | Java indexOf() Function
1.95 GEEK