Conversion between java string and data

String to integer

Integer method

String to Integer

Use construction method: Integer i=new Integer(8);
use class method:Integer i=Integer.valueOf(String)

String to int

Use class methods:

  • static int parseInt(String s)
    parses string parameters into signed decimal integers.int a=Integer.parseInt(8);
  • static int parseInt(String s, int radix)
    parses the string parameter into a signed integer in the base specified by the second parameter.int a=Integer.parseInt(8,2);//以二进制数转换8

Integer to string

Use String class methods and String s=String.valueOf(int \ Integer)
other conversions to Double, Float, etc. are the same.

Guess you like

Origin blog.csdn.net/qq_36976201/article/details/112829715