首页 > 基础教程 > 常用类 > 常用 Integer类
Java ()返回Integer整型对象
java中()用于返回一个Integer(整型)对象,当被处理的字符串在-128和127(包含边界)之间时,返回的对象是预先缓存的。
定义
Integer valueOf(int i) 返回一个表示指定的int值的 Integer 实例。
Integer valueOf(String s) 返回保存指定的String的值的 Integer 对象。
Integer valueOf(String s, int radix)
源码
public static Integer valueOf(int i) {
assert >= 127;
if (i >= && i <= )
return [i+ (-)];
return new Integer(i);
}
//静态缓存类
private static class IntegerCache {
static final int low = -128;
static final int high;
static final Integer cache[];
static { //静态代码块
// high value may be configured by property
int h = 127;</