Java string after class Job 2

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.