首页 > 其他 > 详细

基本数据包装类

时间:2019-04-21 01:25:24      阅读:206      评论:0      收藏:0      [点我收藏+]

基本类型对应的包装类

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

 

基本数据包装类

原文:https://www.cnblogs.com/yifengs/p/10743435.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!