Java String Common Methods collection

Source: Internet
Author: User

String a = "abc";
String B = "abc";
a==b;//returns True because A, B points to the same address


String a = new string ("abc");
String b = new String ("abc");
a==b;//returns false because A, B does not point to the same address
------------------------------------------------------------
A = "abc def";
b = "abc Def";
A.charat (2);//Find the character labeled 2
A.compareto ("ABC");//And the string is larger than the size until one character is not the same
A.concat ("Ghi");//a = a + "GHI"; same effect
A.endswith ("def");//Determine whether to end with Def
A.startwith ("abc");//Determine whether to start with ABC
A.contains ("abc");//Determine if ABC is included
A.equals (b);//Determine whether the contents of a and B strings are equal
A.indexof ("C");//Determine where "C" first appears
A.lastindexof ("C");//Determine the location of the last occurrence of "C"
A.indexof ("C", 2);//Judging from the subscript 2 of the character start, the first occurrence of "C" position
A.length (); Length of//a
A.replace (' C ', ' a ');//Replace "a" with "C" in the string
string[] arr = A.split ("");//string is divided into arrays with spaces
A.substring (3);//start output from subscript 3 until the end
A.substring (3,5);//Output subscript 3 to 5 characters
A.tolowercase ();//change the string to lowercase
A.touppercase ();//Capitalize the string

Java String Common Methods collection

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.