Methods of the String class use the

Source: Internet
Author: User

String is one of the most commonly used classes in Java, with many string manipulation methods built into it. But never looked carefully at how many of these methods, as well as the use of the various methods of the situation, now tidy up for later access to use.

First, non-static method

1.charAt ()

Gets the character for the given index.

2.codePointAt ()

Gets the Unicode encoded value of the given index character.

3.codePointBefore ()

Gets the Unicode encoded value of the preceding character for the given index.

4.codePointCount ()

The number of code points between the given indexes.

5.compareTo ()

Compares this string to the Unicode encoded value of each character of the given string.

6.compareIgnoreCase ()

Ignores the size of the string comparison method.

7.concat ()

The connection string.

8.contains ()

Determines whether the specified character sequence is included.

9.contentEquals ()

Determines whether the specified character sequence charsequence or StringBuffer is the same.

10.endswith ()

Determines whether to end with the specified suffix.

11.equals ()

Determines whether the specified object is the same.

12.equalsIgnoreCase ()

Determines whether the specified string is the same if the size is ignored.

13.getBytes ()

Encodes the specified range string in the default character encoding or the specified character encoding, and stores the result in a byte array.

14.getChars ()

Stores the specified substring at the specified position in the character array.

15.hashCode ()

Gets the hash code of the string variable.

16.indexOf ()

Gets the index of the specified character or string.

17.intern ()?

Gets the standard representation of a variable from a string pool. This is not understood?

I myself understand that if a given string in the string pool returns a reference, if not, a string is generated and the reference is returned.

18.isEmpty ()

Determines whether the string is empty.

19.lastIndexOf ()

Similar to indexof (), the index of the specified character or string is obtained, but the difference is that lastIndexOf () is searched from the tail of the string.

20.length ()

Get string character length

21.matches ()

Determines whether the string conforms to the specified regular expression.

22.offsetByCodePoints ()?

Not at the moment?

23.regionMatches ()

Determines whether a string is equal to the specified range of the specified string (there is an option to ignore the size).

24.replace ()

Replaces the specified character or sequence of characters in a string with the specified character or sequence of characters.

25.replaceAll ()

Replaces all substrings in a string that match the specified regular expression with the specified string.

26.replaceFirst ()

The effect is similar to the previous one, but replaces only the first conforming substring.

27.split ()

Splits a string into a string array using the specified regular expression.

28.subSequence ()

Gets the character sequence of the specified range in the string, with the return type of interface charsequence.

29.subString ()

Gets a substring of the specified range in a string that returns a type of string.

30.toCharArray ()

Converts a string into a character array.

31.toLowerCase ()

Converts a string to lowercase.

32.toString ()

Returns itself.

33.toUpperCase ()

Converts a string to uppercase.

34.trim ()

Remove the spaces at both ends of the string.

Second, static method

1.copyValueOf ()

Converts a character array to a string.

2.format ()?

I don't know how to use it for the time being.

3.join ()

Joins each character sequence using the specified delimiter.

4.valueOf ()

Converts the specified content to a string.

The next thing to add is knowledge about Unicode encoding, such as code point code units or confused.

There is also the use of the format () function, the Intern () function, the offsetbycodepoints () function.

Methods of the String class use the

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.