目录

static String toString(int i, int radix)

描述 (Description)

java.lang.Integer.toString(int i, int radix)方法返回由第二个参数radix指定的基数中第一个参数i的字符串表示。如果radix小于Character.MIN_RADIX或大于Character.MAX_RADIX ,然后使用基数10。

以下ASCII字符用作数字: 0123456789abcdefghijklmnopqrstuvwxyz

声明 (Declaration)

以下是java.lang.Integer.toString()方法的声明

public static String toString(int i, int radix)

参数 (Parameters)

  • i - 这是要转换的整数。

  • radix - 这是在字符串表示中使用的基数。

返回值 (Return Value)

此方法返回指定基数中参数的字符串表示形式。

异常 (Exception)

NA

例子 (Example)

以下示例显示了java.lang.Integer.toString()方法的用法。

package com.iowiki;
import java.lang.*;
public class IntegerDemo {
   public static void main(String[] args) {
   Integer i = new Integer(10);
      // returns a string representation of the specified integer with radix 10
      String retval = i.toString(30, 10);
      System.out.println("Value = " + retval);
      // returns a string representation of the specified integer with radix 16
      retval = i.toString(30, 16);
      System.out.println("Value = " + retval);
      // returns a string representation of the specified integer with radix 8
      retval = i.toString(30, 8);
      System.out.println("Value = " + retval);
   }
} 

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

Value = 30
Value = 1e
Value = 36
↑回到顶部↑
WIKI教程 @2018