基本类型对应的包装类

byte   Byte

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

short  Short

char  Character

int    Integer

long  Long

float  Float

double  Double 

boolean  Boolean

字符串转整型

方法1

  //创建Integer对象

  Integer i = new Integer("10");

  //int intValue();

  int a = i.intValue();

  System.out.println(a+10);// 20 说明相加了

方法2

  //使用静态方法

  //static int parseInt(String s);

  int b = Integer.parseInt("20");

  System.out.println(b+10);//    30

整型转字符串

方法1

  //加空字符

    + ""

方法2

  //String toString()

  Integer i2 = new Integer(40);

  String s = i2.toString();

方法3

  //static String toString(int i);

  String s2 = Integer.toString(50);

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄