基本数据包装类

基本类型对应的包装类

byte   Byte

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);

猜你喜欢

转载自www.cnblogs.com/yifengs/p/10743435.html
今日推荐