Java Tut 48: String Methods

0
(0)

Tất cả các phương thức chuỗi

Lớp String có một tập hợp các phương thức dựng sẵn mà bạn có thể sử dụng trên các chuỗi.

MethodDescriptionReturn Type
charAt()Returns the character at the specified index (position)char
codePointAt()Returns the Unicode of the character at the specified indexint
codePointBefore()Returns the Unicode of the character before the specified indexint
codePointCount()Returns the Unicode in the specified text range of this Stringint
compareTo()Compares two strings lexicographicallyint
compareToIgnoreCase()Compares two strings lexicographically, ignoring case differencesint
concat()Appends a string to the end of another stringString
contains()Checks whether a string contains a sequence of charactersboolean
contentEquals()Checks whether a string contains the exact same sequence of characters of the specified CharSequence or StringBufferboolean
copyValueOf()Returns a String that represents the characters of the character arrayString
endsWith()Checks whether a string ends with the specified character(s)boolean
equals()Compares two strings. Returns true if the strings are equal, and false if notboolean
equalsIgnoreCase()Compares two strings, ignoring case considerationsboolean
format()Returns a formatted string using the specified locale, format string, and argumentsString
getBytes()Encodes this String into a sequence of bytes using the named charset, storing the result into a new byte arraybyte[]
getChars()Copies characters from a string to an array of charsvoid
hashCode()Returns the hash code of a stringint
indexOf()Returns the position of the first found occurrence of specified characters in a stringint
intern()Returns the canonical representation for the string objectString
isEmpty()Checks whether a string is empty or notboolean
lastIndexOf()Returns the position of the last found occurrence of specified characters in a stringint
length()Returns the length of a specified stringint
matches()Searches a string for a match against a regular expression, and returns the matchesboolean
offsetByCodePoints()Returns the index within this String that is offset from the given index by codePointOffset code pointsint
regionMatches()Tests if two string regions are equalboolean
replace()Searches a string for a specified value, and returns a new string where the specified values are replacedString
replaceFirst()Replaces the first occurrence of a substring that matches the given regular expression with the given replacementString
replaceAll()Replaces each substring of this string that matches the given regular expression with the given replacementString
split()Splits a string into an array of substringsString[]
startsWith()Checks whether a string starts with specified charactersboolean
subSequence()Returns a new character sequence that is a subsequence of this sequenceCharSequence
substring()Returns a new string which is the substring of a specified stringString
toCharArray()Converts this string to a new character arraychar[]
toLowerCase()Converts a string to lower case lettersString
toString()Returns the value of a String objectString
toUpperCase()Converts a string to upper case lettersString
trim()Removes whitespace from both ends of a stringString
valueOf()Returns the string representation of the specified valueString

❮ TrướcKế tiếp ❯

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Related posts

Java Tut 49: Phương thức toán học Java ( Java Math)

Java Tut 47: Từ khóa Java

Java Tut 46 : Thêm 2 số