Substring,split Method--get substrings, split the numbers

Source: Internet
Author: User

1.2.31 substring Method--Get substring
Book > Java Program Development Reference manual for this article


The substring method implements the interception of a string from the specified index position until the end of the string, and returns a new string.

Syntax 1 public String subString (int beginindex)

Return value: The specified substring.

Parameter: Beginindex is the index at the beginning (including the location).

Example This example uses the substring method to intercept the string strcom, where the index position is truncated from 3 to the end of the string strcom, and the result of the interception is assigned to the string type variable strresult.

String strcom = "I like Java"; Define a string

String strresult = strcom.substring (3);

System.out.println (strresult);

Syntax 2 public String subString (int beginindex, int endIndex)

Return value: The specified substring.

Parameter: Beginindex is the index at the beginning (including the location).

Parameter: Endindex is the end index (excluding the index location).

Example the method implements the beginindex of a string starting at the specified index position until the index position is (ENDINDEX-1) ends and returns a new string of length (Endindex-beginindex).

This example uses the substring method to intercept the string strcom, starting at index position 3 to end at index position 5, and assigning the truncated string to the string type variable strresult.

String strcom = "I like Java"; Define a string

String strresult = strcom.substring (3,5);

System.out.println (strresult);

Split the numbers, hidden a string of strings for a JS reference. Using split splitting to redefine itemcodes numbers
string[] Itemcodes = Hidden.split (",");

Substring,split Method--get substrings, split the numbers

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.