Java Long.toString(long i, int radix)

Syntax

Long.toString(long i, int radix) has the following syntax.

public static String toString(long i,  int radix)

Example

In the following code shows how to use Long.toString(long i, int radix) method.


public class Main {
  public static void main(String[] args) {
    System.out.println(Long.toString(10,8));
    /*w ww  .  j  a v a  2  s.c  om*/
    // returns a string representation of the specified long with radix 10
    String retval = Long.toString(1234567890, 10);
    System.out.println("Value = " + retval);
     
    // returns a string representation of the specified long with radix 16
    retval = Long.toString(1234567890, 16);
    System.out.println("Value = " + retval);
     
    // returns a string representation of the specified long with radix 8
    retval = Long.toString(1234567890, 8);
    System.out.println("Value = " + retval);    
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable