/* * String conversion function: * byte[] getBytes (): Converts the string to a byte array. * char[] ToCharArray (): Converts a string to a character array. * Static string ValueOf (char[] CHS): Turns the character array into a string. * Static string valueOf (int i): turns data of type int into a string. * Note: The valueof method of the string class can turn any type of data into a string. * String toLowerCase (): Turns the string into lowercase. * String toUpperCase (): Turns the string into uppercase. * String concat (String str): Concatenation of strings. */public class Stringdemo {public static void main (string[] args) {//define a String object As String s = "javase";//byte[] GetBytes (): Put the word String into a byte array. byte[] bys = S.getbytes (); for (int x = 0; x < bys.length; + x + +) {System.out.println (bys[x]);} System.out.println ("----------------");//char[] ToCharArray (): Converts a string to a character array. char[] CHS = S.tochararray (); for (int x = 0; x < chs.length; × x + +) {System.out.println (chs[x]);} System.out.println ("----------------");//static String ValueOf (char[] CHS): Turns the character array into a string. String SS = string.valueof (CHS); SYSTEM.OUT.PRINTLN (ss); System.out.println ("----------------");//static string valueOf (int i): turns data of type int into a string. int i = 100; String sss = string.valueof (i); System. OUT.PRINTLN (SSS); System.out.println ("----------------");//String toLowerCase (): Turns the string into lowercase. System.out.println ("toLowerCase:" + s.tolowercase ()); System.out.println ("s:" + s);//System.out.println ("----------------");//String toUpperCase (): Turns the string to uppercase. System.out.println ("toUpperCase:" + s.touppercase ()); System.out.println ("----------------");//String concat (String str): string concatenation. String S1 = "Hello"; String s2 = "World"; String s3 = s1 + s2; String s4 = s1.concat (S2); System.out.println ("S3:" +S3); System.out.println ("S4:" +S4);}}
String conversion functionality