Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Most programming languages implement a position or indexOf method on strings.

This method will return the index of the first character of the substring in the main string.

The following Java code shows the indexOf method:

String haystack = "Hello world, Java is a programming language";
String needle = "Java";
int position = haystack.indexOf(needle);
System.out.println(position); // 13

Specific programming languages

edit edit source