包装类-以Integer为例

Integer:int 包装类
构造方法:基本数据类型通过构造器转换成包装类
字符串通过构造方法转换为包装类,字符串通过包装类的valueOf(String s)转换为包装类
上面两种不适用域Character类
new Integer(int)
new Integer(string)
方法
int Integer.bigcount(a);a转换成二进制后1个个数
byte i.bytevalue();将integer转换成byte
double i.doublevalue();
long i.longvalue();
short i.shortvalue();
float i.floatvalue();
int compareTo(Integer anotherInteger);在数字上比较两个 Integer 对象
boolean integer.equals(anotherInteger);比较两个值是否相同
int i.hashcode();返回值为这个数的本身
String integer.toBinaryString(int i);十进制转二进制
String integer.toHexString(int i);十进制转十六进制
String integer.toOctalString(int i);十进制转八进制
int integer.parseInt(string);将string类型转换成int
String i.tostring();将integer转换成string
String integer.tostring(i);将基本数据类型转换成string
Integer integer.valueof(int);int转换为integer
Integer integer.valueof(string);string转换成integer
String integer.tostring(i);将基本数据类型转换成string表示形式
String integer.tostring(i,j);将基本数据类型转换成i进制的string表示形式
其他数据类型的:
数据类型转换成string tostring()方法
例:String str = Integer.toString(10);
字符串转换成基本数据类型使用parse类型()方法
例:short s = Short.parseshort("123");

 

转载于:https://www.cnblogs.com/lukaner/p/7210101.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值