Java string type Method

Source: Internet
Author: User

 

Method Summary
 char charAt(int index) 
ReturnscharValue.
 int codePointAt(int index) 
Returns the characters (UNICODE code points) at the specified index ).
 int codePointBefore(int index) 
Returns the character (UNICODE Code Point) before the specified index ).
 int codePointCount(int beginIndex, int endIndex) 
Return thisStringNumber of Unicode code points in the specified text range.
 int compareTo(String anotherString) 
Compares two strings in alphabetical order.
 int compareToIgnoreCase(String str) 
Compare two strings in alphabetical order, regardless of case.
 String concat(String str) 
Link the specified string to the end of the string.
 boolean contains(CharSequence s) 
True is returned only when this string contains the specified sequence of char values.
 boolean contentEquals(CharSequence cs) 
If and only whenStringReturns the same char value as the specified sequence.True.
 boolean contentEquals(StringBuffer sb) 
If and only whenStringIndicatesStringbufferReturns the same character sequence.True.
static String copyValueOf(char[] data) 
Returns the string that represents the character sequence in the specified array.
static String copyValueOf(char[] data, int offset, int count) 
Returns the string that represents the character sequence in the specified array.
 boolean endsWith(String suffix) 
Test whether the string ends with the specified suffix.
 boolean equals(Object anObject) 
Compare this string with the specified object.
 boolean equalsIgnoreCase(String anotherString) 
Set thisStringWith anotherStringFor comparison, case-insensitive.
static String format(Locale l, String format, Object... args) 
Returns a formatted string using the specified language environment, format string, and parameter.
static String format(String format, Object... args) 
Returns a formatted string using the specified format string and parameters.
 byte[] getBytes() 
Use the default Character Set of the platformStringDecodes the data into a byte sequence and stores the results in a new byte array.
 void getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin) 
Expired. This method cannot correctly convert characters into bytes. From JDK 1.1, the preferred method to complete the conversion is throughgetBytes()Constructor. This method uses the default Character Set of the platform.
 byte[] getBytes(String charsetName) 
Use the specified character setStringDecodes the data into a byte sequence and stores the results in a new byte array.
 void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) 
Copy the character string to the target character array.
 int hashCode() 
Returns the hash code of this string.
 int indexOf(int ch) 
Returns the index of the first occurrence of the specified character in this string.
 int indexOf(int ch, int fromIndex) 
Searches from the specified index and returns the index at the specified character for the first time in this string.
 int indexOf(String str) 
Returns the index of the first occurrence of the specified substring in this string.
 int indexOf(String str, int fromIndex) 
Returns the index of the first occurrence of the specified substring from the specified index.
 String intern() 
Returns the canonicalized representation of string objects.
 int lastIndexOf(int ch) 
Returns the index of the last occurrence of the specified character in this string.
 int lastIndexOf(int ch, int fromIndex) 
Start Backward Search from the specified index, and return the index of the last occurrence of the specified character in this string.
 int lastIndexOf(String str) 
Returns the index of the rightmost substring in this string.
 int lastIndexOf(String str,
int fromIndex)
 
Searches backward from the specified index and returns the index of the specified sub-string that appears the last time in this string.
 int length() 
Returns the length of this string.
 boolean matches(String regex) 
Indicates whether the string matches the given regular expression.
 int offsetByCodePoints(int index, int codePointOffset) 
Return thisStringFromindexOffsetcodePointOffsetCode points.
 boolean regionMatches(boolean ignoreCase, int toffset, String other,
int ooffset, int len)
 
Test whether the two string regions are equal.
 boolean regionMatches(int toffset, String other,
int ooffset, int len)
 
Test whether the two string regions are equal.
 String replace(char oldChar, char newChar) 
Returns a new string by usingnewCharReplace alloldChar.
 String replace(CharSequence target, CharSequence replacement) 
Replace this string with each substring that matches the target sequence of the literal value.
 String replaceAll(String regex, String replacement) 
Replace this string with the given replacement string to match each substring of the given regular expression.
 String replaceFirst(String regex, String replacement) 
Replace the string with the given replacement string to match the first substring of the given regular expression.
 String[] split(String regex) 
Splits the string based on the matching of the given regular expression.
 String[] split(String regex, int limit) 
Splits the string based on the given regular expression.
 boolean startsWith(String prefix) 
Test whether the string starts with the specified prefix.
 boolean startsWith(String prefix,
int toffset)
 
Test whether the string starts with the specified prefix. The prefix starts with the specified index.
 CharSequence subSequence(int beginIndex, int endIndex) 
Returns a new character sequence, a subsequence of this sequence.
 String substring(int beginIndex) 
Returns a new string, which is a substring of this string.
 String substring(int beginIndex, int endIndex) 
Returns a new string, which is a substring of this string.
 char[] toCharArray() 
Converts a string to a new character array.
 String toLowerCase() 
Use the rules of the default language environmentStringAll characters in are converted to lowercase letters.
 String toLowerCase(Locale locale) 
Use the givenLocaleThe ruleStringAll characters in are converted to lowercase letters.
 String toString() 
Returns the object itself (it is already a string !).
 String toUpperCase() 
Use the rules of the default language environmentStringAll characters in are converted to uppercase letters.
 String toUpperCase(Locale locale) 
Use the givenLocaleThe rule sets thisStringAll characters in are converted to uppercase letters.
 String trim() 
Returns a copy of the string, ignoring leading and trailing spaces.
static String valueOf(boolean b) 
ReturnbooleanParameter string representation.
static String valueOf(char c) 
ReturncharParameter string representation.
static String valueOf(char[] data) 
ReturncharString Representation of array parameters.
static String valueOf(char[] data, int offset, int count) 
ReturncharThe string representation of the special sub-array of the array parameter.
static String valueOf(double d) 
ReturndoubleParameter string representation.
static String valueOf(float f) 
ReturnfloatParameter string representation.
static String valueOf(int i) 
ReturnintParameter string representation.
static String valueOf(long l) 
ReturnlongParameter string representation.
static String valueOf(Object obj) 
ReturnObjectParameter string representation.

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.