🌐
Career Karma
careerkarma.com › blog › java › java indexof(): a how-to guide
Java indexOf(): A How-To Guide: A Tutorial | Career Karma
December 1, 2023 - You can use a second argument to start your search after a particular index number in the string. If the specified letter or letters cannot be found, indexOf() returns -1. Do you want to become a professional Java developer?
🌐
Programiz
programiz.com › java-programming › library › string › indexof
Java String indexOf()
result = str1.indexOf("ava"); System.out.println(result); // 7 // substring not in the string · result = str1.indexOf("java"); System.out.println(result); // -1 // index of empty string in the string
🌐
W3Resource
w3resource.com › java-tutorial › string › string_indexof.php
Java String: indexOf Method - w3resource
August 19, 2022 - Java Platform: Java SE 8 · Syntax: ... represented by this object that is greater than or equal to fromIndex, or -1 if the character does not occur....
🌐
CodingBat
codingbat.com › doc › java-string-indexof-parsing.html
Java String indexOf Parsing
The indexOf(String target) method searches left-to-right inside the given string for a "target" string. The indexOf() method returns the index number where the target string is first found or -1 if the target is not found.
🌐
iO Flood
ioflood.com › blog › indexof-java
Java's String IndexOf Method: A Detailed Usage Guide
February 26, 2024 - The indexOf() method in Java is ... of the first occurrence of the specified character or substring. If it does not occur as a substring, -1 is returned....
🌐
javaspring
javaspring.net › blog › java-indexof-1
Java `indexOf` Method: A Comprehensive Guide — javaspring.net
indexOf(int ch): This method takes a single character (represented as an int in Java) and returns the index of the first occurrence of the specified character within the string. If the character is not found, it returns -1.
🌐
freeCodeCamp
freecodecamp.org › news › indexof-in-java-how-to-find-the-index-of-a-string-in-java
indexOf in Java – How to Find the Index of a String in Java
March 24, 2022 - Lastly, when we pass in a character or substring that doesn't exist in a string, the indexOf method will return a value of -1.
🌐
W3Schools
w3schools.com › java › ref_string_indexof.asp
Java String indexOf() Method
Java Examples Java Videos Java Compiler Java Exercises Java Quiz Java Code Challenges Java Practice Problems Java Server Java Syllabus Java Study Plan Java Interview Q&A ... String myStr = "Hello planet earth, you are a great planet."; System.out.println(myStr.indexOf("planet"));
Find elsewhere
🌐
Quora
quora.com › What-is-the-indexOf-method-in-Java
What is the indexOf() method in Java? - Quora
Answer: The [code ]indexOf()[/code] method in Java is a method of the [code ]String[/code] class that returns the index (position) of the first occurrence of a specified string or character within a string. It returns -1 if the specified string or character is not found. The syntax for using this...
🌐
FavTutor
favtutor.com › blogs › java-indexof
indexOf Method in Java (with Examples)
November 18, 2023 - The indexOf() method is a member ... which represents the position of the character or substring. If the character or substring is not found, the method returns -1....
🌐
Tutorialspoint
tutorialspoint.com › java › java_string_indexof.htm
Java String indexOf() Method
This method returns the index within this string of the first occurrence of the specified character or -1, if the character does not occur. ... See the description. import java.io.*; public class Test { public static void main(String args[]) ...
🌐
TutorialsPoint
tutorialspoint.com › java › util › vector_indexof_index.htm
java.util.Vector.indexOf() Method
Following is the declaration for java.util.Vector.indexOf() method ... The method call returns the index of the first occurrence of the object argument in this vector at position index or later in the vector.
🌐
Medium
medium.com › @AlexanderObregon › javas-arraylist-indexof-method-explained-6bb47ce4c894
Java’s ArrayList.indexOf() Method Explained | Medium
August 19, 2024 - In this example, the indexOf() method returns 0 for the first occurrence of 42 and -1 for 100 since it is not present in the list.
🌐
TechVidvan
techvidvan.com › tutorials › string-indexof-method-in-java
Java String indexOf() Method with Examples - TechVidvan
May 6, 2025 - An int value reflecting the index of the character’s first occurrence in the string, or -1 if it never occurs. ... The indexof() method searches the supplied Substring beginning at the beginning of the string.
🌐
Medium
medium.com › @naiduharsha95 › indexof-in-java-4833ae7315e8
indexOf() in Java
August 4, 2025 - The indexOf() method is part of the String class in Java. It returns the index of the first occurrence of a specified character or substring. If the character or substring isn’t found, it returns -1.
🌐
Udemy
blog.udemy.com › home › it & development › software development › understanding the java string indexof method
Understanding the Java String IndexOf Method - Udemy Blog
April 14, 2026 - These overload methods have been described below. ... This method returns the index of the character ‘c’ passed as parameter. If the specified character is not present in the string, the returned index would be -1.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-string-indexof
Java String indexOf() Method - GeeksforGeeks
November 19, 2024 - In this article, we will learn various ways to use indexOf() in Java. Example: Below is the simplest way that returns the index of the first occurrence of a specified character in a string, or -1 if the character does not occur.
🌐
Vultr Docs
docs.vultr.com › java › standard-library › java › lang › String › indexOf
Java String indexOf() - Find Character Index | Vultr Docs
December 17, 2024 - In this example, since 'x' does not appear in the sentence "This is a test", indexOf() returns -1, indicating the absence of the character. Sometimes, you might need to start your search from a specific position in the string.
🌐
CodeGym
codegym.cc › java blog › strings in java › java string indexof()
Java String indexOf()
December 26, 2024 - We used a while loop to iterate over all occurrences of the character or substring until the indexOf() method returns -1, which indicates that there are no more occurrences of the character or substring in the string.