function of fetching substring substring () __ function

Source: Internet
Author: User
SUBSTRING (int index) starts with index Word to the last (string starts counting from 0)
substring (int beginindex, int endindex) starts with the index Word to Endindex (string is counted from 0, this does not include the first endindex character) substring
The public string substring (int beginindex) returns a new string, which is a substring of this string. The substring begins at the specified index at the end of the string.
For example:

"Unhappy". SUBSTRING (2) returns "Happy"
"Harbison". SUBSTRING (3) returns "Bison"
"Emptiness". SUBSTRING (9) returns "" (An empty string)

Parameters:
Beginindex-Index at the beginning (including).
Return:
The specified substring.
Thrown:
Indexoutofboundsexception-if beginindex is negative or greater than the length of this String object.


Substring
public string substring (int beginindex, int endindex) returns a new string, which is a substring of this string. The substring starts at the specified Beginindex and continues to the character at the index endIndex-1. Therefore, the length of the substring is endindex-beginindex.
Example:

"Hamburger". Substring (4, 8) returns "Urge"
"Smiles". Substring (1, 5) returns "Mile"

Parameters:
Beginindex-Index at the beginning (including).
Endindex-the index at the end (not included).
Return:
The specified substring.
Thrown:
Indexoutofboundsexception-If Beginindex is negative, or endindex is greater than the length of this String object, or Beginindex is greater than endindex.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.