Reference×
Reference
- [] (array access)
- = (assign)
- catch
- class
- // (comment)
- , (comma)
- {} (curly braces)
- /** */ (doc comment)
- . (dot)
- draw()
- exit()
- extends
- final
- false
- import
- implements
- loop()
- /* */ (multiline comment)
- new
- noLoop()
- null
- () (parentheses)
- popStyle()
- pop()
- pushStyle()
- push()
- private
- public
- redraw()
- return
- ; (semicolon)
- setLocation()
- setResizable()
- setTitle()
- setup()
- static
- super
- thread()
- this
- try
- void
- true
Name
substring()
Class
String
Description
Returns a new string that is a part of the original string. When using the endIndex parameter, the string between beginIndex and endIndex-1 is returned.
Examples
String str1 = "CCCP"; String str2 = "Rabbit"; String ss1 = str1.substring(2); // Returns "CP" String ss2 = str2.substring(3); // Returns "bit" String ss3 = str2.substring(0, 2); // Returns "Ra" println(ss1 + ":" + ss2 + ":" + ss3); // Prints "CP:bit:Ra"
Syntax
str.substring(beginIndex)
str.substring(beginIndex, endIndex)
Parameters
str
String: any variable of type StringbeginIndex
int: position from which to begin (inclusive)endIndex
int: position from which to end (exclusive)
Return
String

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