String

xiaoxiao2021-03-06  80

Public Final Class String Implements Java.io.Serializable, Compailable, Charsequence

Constructor

In fact, there is no need to construct a function, and you can use it directly.

a. Common constructor:

Public String (Char value []) public string (char value [], int offset, int count)

b. Almost unused constructor

Public string () // Almost no use of public string (String Original), you should use string s = "helloworld"; instead of string s = new string ("HelloWorld"); public string (byte bytes [], int offset , Int Length, String Charsetname, PUBLIC STRING (Byte Bytes [], String Charsetname) Public String (byte bytes [], int offset, int length) public string (byte Bytes []) I don't know how to have these

C. Obsolete

Public string (byte ascii [], int hibyte, int offset, int count) public string (byte ascii [], int hibyte)

2. Common methods

Public int length () // This method returns the length of the string, that is, the number of characters, not byte size, the character size should be 2 * length () public char charat (int index) // Specify position public boolean equals (Object anObject) // compare two strings public boolean equalsIgnoreCase (string anotherString) // compare two strings, ignoring case public byte [] getBytes () public byte [] getBytes (string charsetName) public boolean startsWith (String prefix, int toffset) public boolean startsWith (String prefix) public boolean endsWith (String suffix) public int hashCode () public int indexOf (int ch) public int indexOf (int ch, int fromIndex) public int lastIndexOf (int ch ) public int lastIndexOf (int ch, int fromIndex) public int indexOf (String str) public int indexOf (String str, int fromIndex) public int lastIndexOf (String str) public int lastIndexOf (String str, int fromIndex) public String substring (int beginIndex) public String substring (int beginIndex, int endIndex) public CharSequence subSequence (int beginIndex, int endIndex) public String replace (char oldChar, char newChar) public String toLowerCase (locale locale) public String toLower Case () public String toUpperCase (Locale locale) public String toUpperCase () public String trim () public char [] toCharArray () public static String valueOf (Object obj) public static String valueOf (char data []) public static String valueOf ( char data [], int offset, int count) public static String valueOf (boolean b) public static String valueOf (char c) public static String valueOf (int i) public static String valueOf (long l) public static String valueOf (float f ) public static string valueof (double d) 3. Little use

public void getChars (int srcBegin, int srcEnd, char dst [], int dstBegin) public void getBytes (int srcBegin, int srcEnd, byte dst [], int dstBegin) public boolean contentEquals (StringBuffer sb) public int compareTo (String anotherString) Public int compareto (Object O) // Implementing the Comparable interface PUBLIC INT ComparetoIgnorecase (String Str) public string concat (String str) // can be used number, so few use this public string toString () public native string INTERN () 4. Excess

Public Static String CopyValueof (Char Data [], INT Offset, INT Count) Public Static String CopyValueof (Char Data [])

5. Method for difficult

public boolean matches (String regex) public String replaceFirst (String regex, String replacement) public String replaceAll (String regex, String replacement) public String [] split (String regex, int limit) public String [] split (String regex) // The above method is related to the regular expression, it is more difficult to use.

6. I can't do it.

Public Static Final Comparator case_insensitive_order // This is used to implement comparison of String case insensitive comparators, why is it to be used as public, it is only useful for String, and it should not be public.

Public Boolean RegionMatches (int tent, int LEN) Public Boolean RegionMatches (Boolean Ignorecase, Int Toffset, String Other, Int Ooffset, Int Len) // I don't think this two should not be PUBLIC

转载请注明原文地址:https://www.9cbs.com/read-95655.html

New Post(0)