Int,char,string three types of mutual conversions in Java

Source: Internet
Author: User

How do I convert string strings to integer int? int i = integer.valueof (my_str). Intvalue ();

int I=integer.parseint (str);

How do I convert string strings to integers? Integer integer=integer.valueof (str);

How do I convert an integer int to a string string? 1.) String s = string.valueof (i);
2.) String s = integer.tostring (i);
3.) String s = "" + I;
How do I convert an integer int to an integer? Integer integer=new integer (i);

How do I convert an integer to a string of strings? Integer integer=string

How do I convert an integer to int? int Num=integer.intvalue ();

How do I convert a string to BigDecimal? BigDecimal d_id = new BigDecimal (str);

How do I convert a String to char? Char[] ca= "123". ToCharArray ();
How do I convert char to string?      String s=ca.tostring (); Any type can be converted to a string type with ToString ()

Additional time processing is attached:

SimpleDateFormat SDF = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss:SSS"); Output Time Sdf.format (new Date ()) in 2011-09-21 13:33:24:456 format;

Int,char,string three types of mutual conversions in Java

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.