A common method of Java String

String of common methods induction and summary

  • char charAt (int index) Returns the char value at the specified index.
  • Comparing the string and another object int compareTo (Object o).
  • int compareTo (String anotherString) Compares two strings lexicographically.
  • int compareToIgnoreCase (String str) Compares two strings lexicographically, without regard to case.
  • String concat (String str) the specified string is connected to this end of the string.
  • boolean endsWith (String suffix) Tests if this string ends with the specified suffix.
  • Comparative boolean equals (Object anObject) this string to the specified object.
  • boolean equalsIgnoreCase (String anotherString) compare this String to another String, ignoring case considerations.
  • byte [] the getBytes () using the platform's default character set encoding is byte String this sequence, storing the result into a new byte array.
  • byte [] getBytes (String charsetName) using the specified character set coding this String is byte sequence, and storing the result into a new byte array.
  • void getChars (int srcBegin, int srcEnd, char [] dst, int dstBegin) characters from the character string copied to the target array.
  • int hashCode () Returns the hash code of this string.
  • int indexOf (int ch) Returns the index of the character string appears in this first time.
  • int indexOf (int ch, int fromIndex) Returns the index of the substring in the first occurrence of the string.
  • int indexOf (String str, int fromIndex) Returns the index of the substring in the first occurrence of the string, starting at the specified index.
  • String intern () Returns a string representation of the normalized object.
  • int lastIndexOf (int ch) Returns the index within this string of characters at the last occurrence.
  • int lastIndexOf (int ch, int fromIndex) Returns the index within this string of characters at the last occurrence, began to reverse search from the specified index.
  • int lastIndexOf (String str) Returns the specified substring in this string of the rightmost occurrence index.
  • int lastIndexOf (String str, int fromIndex) Returns the substring index within this string of the last occurrence, starting at the specified index reverse lookup.
  • int length () Returns the length of this string.
  • boolean matches (String regex) Tell whether this string matches the given regular expression.
  • String replace (char oldChar, char newChar) Returns a new string, which is obtained by replacing all oldChar this string with newChar obtained.
  • String replaceAll (String regex, String replacement) replacing the given replacement string matches all given regular expression substring.
  • String replaceFirst (String regex, String replacement) replacing the given replacement string matches the given regular expression first substring.
  • String [] split (String regex) expression matching Splits this string given positive.
  • String [] split (String regex, int limit) according to match a given regular expression to split this string.
  • boolean startsWith (String prefix) Tests if this string to the specified prefix beginning.
  • boolean startsWith (String prefix, int toffset) Tests if this string substring from the specified index starts with the specified prefix.
  • String substring (int beginIndex) Returns a new string that is a substring of this string.
  • String substring (int beginIndex, int endIndex) Returns a new string that is a substring of this string.
  • char [] toCharArray () converts this string to a new character array.
  • String toLowerCase () using rules for the default locale convert all the characters in this String to lowercase.
  • String toLowerCase (Locale locale) to use the rules given Locale String all the characters in this are converted to lowercase.
  • String toString () Returns the object itself (which is already a string!).
  • String toUpperCase () using rules for the default locale String all the characters in this are converted to uppercase.
  • String toUpperCase (Locale locale) to use the rules given Locale String all the characters in this are converted to uppercase.
  • String trim () Returns a copy of the string, ignoring leading and trailing whitespace.
  • static String valueOf (primitive data type x) returns the string for the given data type representation of the argument x type.
Published 29 original articles · won praise 33 · views 5122

Guess you like

Origin blog.csdn.net/lxn1214/article/details/104641055