String,int,integer,char, double type conversions in Java

Source: Internet
Author: User

Transfer from http://blog.csdn.net/zhang103886108/article/details/42917693

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

int I=integer.parseint (str);

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

3. How to convert integer int into string string?
1.) String s = string.valueof (i);
2.) String s = integer.tostring (i);
3.) String s = "" + I;

4. How do I convert an integer int to an integer?
Integer integer=new integer (i);

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

12, string to double

String s;

Double ss=double.parsedouble (s);

Note: parsedouble parseint returns a double.

Double and Integer are encapsulated classes of double and int that need to be converted to a string type.

String,int,integer,char, double type 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.