标签:ann ignore encode sub name following sequence data char
public String(char[] value) Allocates a new String so that it represents the sequence of characters currently contained in the character array argument. The contents of the character array are copied; subsequent modification of the character array does not affect the newly created string. Parameters: value - The initial value of the string
public String(char[] value, int offset, int count) Allocates a new String that contains characters from a subarray of the character array argument. The offset argument is the index of the first character of the subarray and the count argument specifies the length of the subarray. The contents of the subarray are copied; subsequent modification of the character array does not affect the newly created string. Parameters: value - Array that is the source of characters offset - The initial offset count - The length Throws: IndexOutOfBoundsException - If the offset and count arguments index characters outside the bounds of the value array
charAt(int index) Returns the char value at the specified index.
public class test1 { public static void main(String args[]) { String str = "hello"; char c = str.charAt(1); System.out.println(c); } } //e
toCharArray() Converts this string to a new character array.
public class test1 { public static void main(String args[]) { String str = "hello"; char [] data = str.toCharArray(); for(int i=0;i<data.length;i++) { data[i]-=32;//转大写 System.out.print(data[i]+","); } System.out.println(new String(data));//将字符数组转化为字符串 } }
String(byte[] bytes) Constructs a new String by decoding the specified array of bytes using the platform‘s default charset.
String(byte[] bytes, int offset, int length) Constructs a new String by decoding the specified subarray of bytes using the platform‘s default charset.
public byte[] getBytes() Encodes this String into a sequence of bytes using the platform‘s default charset, storing the result into a new byte array. The behavior of this method when this string cannot be encoded in the default charset is unspecified. The CharsetEncoder class should be used when more control over the encoding process is required. Returns: The resultant byte array Since: JDK1.1
public byte[] getBytes(String charsetName) throws UnsupportedEncodingException Encodes this String into a sequence of bytes using the named charset, storing the result into a new byte array. The behavior of this method when this string cannot be encoded in the given charset is unspecified. The CharsetEncoder class should be used when more control over the encoding process is required. Parameters: charsetName - The name of a supported charset Returns: The resultant byte array Throws: UnsupportedEncodingException - If the named charset is not supported Since: JDK1.1
public boolean equals(Object anObject) Compares this string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object. Overrides: equals in class Object Parameters: anObject - The object to compare this String against Returns: true if the given object represents a String equivalent to this string, false otherwise See Also: compareTo(String), equalsIgnoreCase(String)
public boolean equalsIgnoreCase(String anotherString) Compares this String to another String, ignoring case considerations. Two strings are considered equal ignoring case if they are of the same length and corresponding characters in the two strings are equal ignoring case. Two characters c1 and c2 are considered the same ignoring case if at least one of the following is true: The two characters are the same (as compared by the == operator) Applying the method Character.toUpperCase(char) to each character produces the same result Applying the method Character.toLowerCase(char) to each character produces the same result Parameters: anotherString - The String to compare this String against Returns: true if the argument is not null and it represents an equivalent String ignoring case; false otherwise See Also: equals(Object)
public int compareTo(String anotherString) Specified by: compareTo in interface Comparable<String> Parameters: anotherString - the String to be compared. Returns: the value 0 if the argument string is equal to this string; a value less than 0 if this string is lexicographically less than the string argument; and a value greater than 0 if this string is lexicographically greater than the string argument. compareToIgnoreCase
字符串查找
1.
标签:ann ignore encode sub name following sequence data char
原文地址:https://www.cnblogs.com/xhnxhnu/p/9131330.html