Tag: lang character array case boolean length description off trim BSP
String.Equals () Method:
public boolean equals (Object anobject) { if (this = = AnObject) { return true; } if (anobject instanceof string) { string anotherstring = (string) anobject; int n = count; if (n = = anotherstring.count) { char v1[] = value; Char v2[] = Anotherstring.value; int i = offset; int j = Anotherstring.offset; while (n--! = 0) { if (v1[i++]! = v2[j++]) return false; } return true; } } return false;}
Instructions for using the String class method:
1.int Length ():
Returns the string length.
2.char charAt (int n):
Returns the char value at the specified index, ranging from 0 to length ()-1. 3.getChars (int srcbegin,int srcend, char[] dst,int dstbegin)
Gets the substring copied from the specified position into the character array. The first character to be copied is at index Srcbegin, and the last character to be copied is at index srcEnd-1 (so the total number of characters to be copied is Srcend-srcbegin). The characters to be copied to the DST sub-array start at index Dstbegin and end at index.
4.String replace (char Oldchar,char newchar) substring substitution:
Returns a new string that is obtained by replacing all Oldchar that appear in this string with Newchar. If Oldchar does not appear in the character sequence represented by this string object, a reference to this string object is returned. Otherwise, a new string object is created that represents a sequence of characters in addition to all oldchar that are replaced with Newchar, which is the same as the sequence of characters represented by this string object.
5.String toLowerCase ():
Converts all characters in this string to lowercase
6.String toUpperCase ():
Converts all characters in this string to uppercase
7.String Trim ():
Remove the Kinsoku space:
8.char[] ToCharArray ():
Convert a String object to a character array
Java string after class Job 2