The method for converting seven data types, such as int, double, boolean, char, float, long, object, to string data types, is string.valueof ();

Source: Internet
Author: User

int, double, boolean, char, float, long, object type data converted to String//int type into a string type int h=123456; String l=string.valueof (h); SYSTEM.OUT.PRINTLN ("int type converted to String type:" +l);//double type to stringdouble a=1.1; String a=string.valueof (A); System.out.println ("Double type to String:" +a);//boolean type to String type Boolean b=false; String b=string.valueof (B); System.out.println ("Boolean type to String type:" +b);//char type to String type char d= ' a '; String d=string.valueof (D); System.out.println ("char type to String type:" +d);//char type array converted to string type char[] e={' A ', ' B ', ' C '}; String e=string.valueof (E); System.out.println ("char type array is converted to String type:" +e);//char type array in which several data are converted to string char []f={' a ', ' B ', ' C ', ' d '}; String f=string.valueof (F, 0, 3); System.out.println ("Some of the data in the Char type array is converted to String type:" +f);//float type is converted to string type float g=123; String g=string.valueof (G); System.out.println ("float type is converted to String type:" +g);//long type is converted to string type long j=123342; String j=string.valueof (J); System.out.println ("Long is converted to String type:" +j);//object type is converted to string type Object k=c; String k=string.valueof (K); System.out.println ("ObThe ject type is converted to String type: "+k"; System.out.println ("\ n");//double type to long type double P=88.88;long p=math.round (d);   System.out.println ("Double type to Long type:" +p);p =p; Force type Conversion System.out.println ("Double type to Long type:" +p);//float type to long type float Q=123;long q=math.round (q); System.out.println ("Float type to Long type:" +q);
q=q; Force type conversion System.out.println ("Float type to Long type" +q);

Code to run:


  

The method for converting seven data types, such as int, double, boolean, char, float, long, object, to string data types, is string.valueof ();

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.