Java.lang Package Classes

Java Long - toUnsignedString() Method



The java.lang.Long.toUnsignedString() method returns a string representation of the argument as an unsigned decimal value. The argument is converted to unsigned decimal representation and returned as a string exactly as if the argument and radix 10 were given as arguments to the toUnsignedString(long, int) method.

Syntax

public static String toUnsignedString(long i)

Parameters

i Specify an integer to be converted to an unsigned string.

Return Value

Returns an unsigned string representation of the argument.

Exception

NA.

Example:

In the example below, the java.lang.Long.toUnsignedString() method is used to convert the given long value to a string by an unsigned conversion.

import java.lang.*;

public class MyClass {
  public static void main(String[] args) {
    
    //creating long value
    long x = 25;
    long y = 111;

    //printing UnsignedString value of long values
    System.out.println("UnsignedString value of x is: " + Long.toUnsignedString(x)); 
    System.out.println("UnsignedString value of y is: " + Long.toUnsignedString(y));  
  }
}

The output of the above code will be:

UnsignedString value of x is: 25
UnsignedString value of y is: 111

❮ Java.lang - Long