Java.lang Package Classes

Java Integer - toUnsignedString() Method



The java.lang.Integer.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(int, int) method.

Syntax

public static String toUnsignedString(int 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.Integer.toUnsignedString() method returns a string representation of the argument as an unsigned decimal value.

import java.lang.*;

public class MyClass {
  public static void main(String[] args) {

    //creating int values
    int x = 25;
    int y = -25;

    //creating toUnsignedString value of int values
    String p = Integer.toUnsignedString(x);
    String q = Integer.toUnsignedString(y);

    //printing toUnsignedString value of int values
    System.out.println("toUnsignedString value of x is: " + p); 
    System.out.println("toUnsignedString value of y is: " + q);  
  }
}

The output of the above code will be:

toUnsignedString value of x is: 25
toUnsignedString value of y is: 4294967271

❮ Java.lang - Integer