static Integer valueOf(int i)
描述 (Description)
java.lang.Integer.valueOf(int i)方法返回表示指定int值i的Integer实例。
声明 (Declaration)
以下是java.lang.Integer.valueOf()方法的声明
public static Integer valueOf(int i)
参数 (Parameters)
i - 这是一个int值。
返回值 (Return Value)
此方法返回表示i的Integer实例。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.lang.Integer.valueOf()方法的用法。
package com.iowiki;
import java.lang.*;
public class IntegerDemo {
public static void main(String[] args) {
Integer i = new Integer(30);
// returns a Integer instance representing the specified int value
System.out.println("Value = " + i.valueOf(2));
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
Value = 2