String conversion functionality

Source: Internet
Author: User

/* * 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

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.