String function-startswith-endswith-tolowercase-touppercase Learning

Source: Internet
Author: User

 

Package Four; public class stringdemo {public static void main (string ARGs []) {string sour = "The 23th Chinese Film Festival winners .txt"; string head = ""; string tail = ". TXT "; if (sour. startswith (head) {system. out. println ("head is" + head);} // used to determine the file type, very practical! If (sour. endswith (tail) {system. out. println ("tail is" + tail);} // string sour2 = "this is a text with uppercase I am excellent! It can be lowercase, hello. Mixed write hello! How are you? "; System. out. println ("original text:"); system. out. println (sour2); system. out. println ("tolowercase text:"); system. out. println (sour2.tolowercase (); system. out. println ("Text of touppercase:"); system. out. println (sour2.touppercase ());}}

Console printing:

 

Head is
Tail is. txt
Original text:
This is a text with uppercase I am excellent! It can be lowercase, hello. Mixed write hello! How are you?
Text of tolowercase:
This is a text with uppercase I am excellent! It can be lowercase, hello. Mixed write hello! How are you?
Text of touppercase:
This is a text with uppercase I am excellent! It can be lowercase, hello. Mixed write hello! How are you?

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.