Reference×
Reference
- [] (array access)
- = (assign)
- catch
- class
- , (comma)
- // (comment)
- {} (curly braces)
- . (dot)
- /** */ (doc comment)
- draw()
- false
- extends
- exit()
- final
- implements
- import
- loop()
- /* */ (multiline comment)
- new
- noLoop()
- null
- () (parentheses)
- pop()
- popStyle()
- private
- public
- pushStyle()
- push()
- redraw()
- return
- ; (semicolon)
- setLocation()
- setResizable()
- setup()
- setTitle()
- static
- super
- this
- thread()
- true
- try
- void
Name
indexOf()
Class
String
Description
Tests to see if a substring is embedded in a String, and returns the index position of the first occurrence of the substring defined in the str parameter. If the str substring is not found within the String, -1 is returned.
Examples
String str = "CCCP"; int p1 = str.indexOf("C"); int p2 = str.indexOf("P"); int p3 = str.indexOf("CP"); println(p1 + ":" + p2 + ":" + p3); // Prints "0:3:2"
Syntax
str.indexOf(str)
str.indexOf(str, fromIndex)
Parameters
str
String: any variable of type Stringstr
String: the substring to searchfromIndex
int: the index from which to start the search
Return
int

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.