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?