Java substring intercept string

Source: Internet
Author: User

There are two substring () functions in String, as follows: one: String.substring (intstart) Parameter: Start: The index of the position to intercept returns: A string from start to end, for example: string str="Hello word!"; System. out. println (Str.substring (1)); System. out. println (Str.substring (3)); System. out. println (Str.substring (6) ; The result will be: Ello word!Lo Word!Ord!if start is greater than the length of the string, an out-of-bounds exception is thrown; II: string.substring (intBeginindex,intendIndex) Parameters: Beginindex Start position index EndIndex End position Index returns: a string from the Beginindex location to the EndIndex location for example: String str="Hello word!"; System. out. println (Str.substring (1,4)); System. out. println (Str.substring (3,5)); System. out. println (Str.substring (0,4) ; The result will be: ell lo hell if startindex and endindex are out of bounds, an out-of-bounds exception will be thrown. 

Java substring intercept string

Related Article

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.