目录

int intValue()

描述 (Description)

java.lang.Byte.intValue()以int形式返回此Byte的值。

声明 (Declaration)

以下是java.lang.Byte.intValue()方法的声明

public int intValue()

指定 (Specified by)

Number intValue

参数 (Parameters)

NA

返回值 (Return Value)

转换为int类型后,此方法返回此对象表示的数值。

异常 (Exception)

NA

例子 (Example)

以下示例显示了lang.Byte.intValue()方法的用法。

package com.iowiki;
import java.lang.*;
public class ByteDemo {
   public static void main(String[] args) {
      // create 2 Byte objects b1, b2
      Byte b1, b2;
      // create 2 int i1, i2
      int i1, i2;
      // assign values to b1, b2
      b1 = new Byte("123");
      b2 = new Byte("-32");
      // assign int values of b1, b2 to i1, i2
      i1 = b1.intValue();
      i2 = b2.intValue();
      String str1 = "int value of Byte " + b1 + " is " + i1;
      String str2 = "int value of Byte " + b2 + " is " + i2;
      // print i1, i2 values
      System.out.println( str1 );
      System.out.println( str2 );
   }
}

让我们编译并运行上面的程序,这将产生以下结果 -

int value of Byte 123 is 123
int value of Byte -32 is -32
↑回到顶部↑
WIKI教程 @2018