×

Java Integer toUnsignedString() method

The toUnsignedString() method of Java Integer class returns a string representation of the argument as an unsigned decimal value. The second syntax returns a string representation of the given argument as an unsigned integer value in the specified second argument. Syntax
  • public static String toUnsignedString (int i)
  • public static String toUnsignedString (int i, int radix)
Parameters The parameter ‘i’ represents an integer to be converted to an unsigned string and the parameter ‘radix’ represents the radix to use in the string representation. Return Value The first syntax of toUnsignedString() method returns an unsigned string representation of the argument. The second syntax returns an unsigned string representation of the argument in the specified radix. Example 1
public class JavaIntegerToUnsignedStringExample1 {
    public static void main(String[] args) {
        //passing negative value
        Integer val=-5667;
        String val1=Integer.toUnsignedString(val);
        //It returns an unsigned string representation of the argument. 
        System.out.println("Unsigned String  Value : "+val1);
    }
}
Output
String  Value : 4294961629
Example 2
public class JavaIntegerToUnsignedStringExample2 {
    public static void main(String[] args) {
        //passing the max value
        Integer val=Integer.MAX_VALUE;
        //passing the max radix
        int radix=Character.MAX_RADIX;
        String val1=Integer.toUnsignedString(val,radix);
      //It returns an unsigned string representation of the argument in the specified radix.
        System.out.println("String  Value : "+val1);
    }
}
Output
String  Value : zik0zj
Example 3
public class JavaIntegerToUnsignedStringExample2 {
    public static void main(String[] args) {
        //passing the min value
        Integer val=Integer.MIN_VALUE;
        //passing the min radix
        int radix=Character.MIN_RADIX;
        String val1=Integer.toUnsignedString(val,radix);
      //It returns an unsigned string representation of the argument in the specified radix.
        System.out.println("String  Value : "+val1);
    }
}
Output
String  Value : 10000000000000000000000000000000

Related Topics

Stack Program in Java

Stack Program in Java The Stack class is part of the collection framework that inherits the Vector class. Thus, the Stack class can also be called a subclass of the Vector...

5 minutes read.

Heap Sort in Java

Heap Sort in JavaHeap sort in Java uses the data structure binary heap, min-heap, or max heap to do the sorting of elements. Since min-heap always gives the minimum element first,...

8 minutes read.

How to Convert double to int in Java

The double is a larger data type than int. When we assign a larger type value to a variable of smaller type, then we need to perform the explicit conversion....

2 minutes read.

Java String hashCode() method

Java String hashCode() method returns hash code for current String. hash code for string object is computed as s[0]*31^(n - 1) + s[1]*31^(n - 2) + ... + s[n - 1] Using int...

2 minutes read.

Java array list remove time complexity

Java: We know that java is one of the programming languages. The main feature of java which is not in C or object oriented programming language is platform independence. Not only the...

7 minutes read.

How to convert float to String in Java

How to convert float to String in java There are following methods to convert float to String: Convert using Float.toString(float) Convert using String.valueOf(float) Convert using Float.toString(float) The Float class has a static method that returns...

2 minutes read.

How to calculate time difference in Java

In this tutorial, we learned about how to calculate time differences in java language and which methods use to find the difference and its example. Prerequisite To understand this example, you need...

5 minutes read.

Diffie Hellman Algorithm in Java

In this section, you will be acknowledged about Diffie Hellman algorithm clearly step wise along with an example and also an example program. Diffie Hellman Algorithm One of the most significant algorithms...

3 minutes read.

How to Convert long to String in Java

How to Convert long to String in java It is used if we have to display a long number in the text field because everything is displayed as a String. A...

3 minutes read.

Java Delete File

There are two techniques to erase a record in Java: Utilizing File.delete() technique.Utilizing File.deleteOnExit() technique. Using File.delete() technique: In Java, we can erase a document by utilizing the File.delete() technique for File class....

2 minutes read.

How to use Lambda Expression in Java?

The new and significant lambda expression feature of Java was added in Java SE 8. It provides a clear and concise mechanism for describing a single method interface using an...

4 minutes read.

Java String intern() method

Java String intern() method returns canonical representation for the String Object. syntax: public String intern() Return: It returns a interned String that to be a pool of unique String. Java String intern() Example 1 public class...

2 minutes read.

Anonymous Function in Java

A function defined as being unbound from an identifier is called an anonymous function. Because they permit access to variables within the scope of the contained function, these are a...

4 minutes read.

Java Destructors

Before knowing about Java destructors, let us know about constructors. If we understand the concept of the constructor, we can easily understand about destructor and also, we will get an...

3 minutes read.

String Coding Interview Questions in Java

What is String in Java?In Java, a String is a Class that is defined in the java.lang package. It isn't a basic data type like int or long. Character Strings...

5 minutes read.

Java Type Casting

Type casting is a technique or process used in Java to convert one data type into another, either manually or automatically. The compiler performs the automatic conversion, and the programmer...

3 minutes read.

Get year from date in Java

The getYear() method of the Java date class returns a number calculated by deducting 1900 from the year that contains or starts with the instant in time represented by this...

4 minutes read.

Java Boolean toValue() Method

The valueOf() method of Java Boolean class returns a Boolean object representing the given Boolean or String value. It returns true, if the specified Boolean or string object is true...

2 minutes read.

Vectors in Java

Vector Class We may make resizable arrays comparable to the ArrayList class using the Vector class, which implements the List interface. A vector is similar to a dynamic collection that can...

4 minutes read.

Java Strings

String class is the most used class in Java programming language. The string is the sequence of characters, which is treated as objects in Java. Creating String objects We create String objects...

5 minutes read.