Java Integer toUnsignedString() MethodThis method is used to get an unsigned String object representing the value of the Number Object. There is two different types of Java toUnsignedString() method which can be differentiated depending on its parameter. These are:
1. Java Integer toUnsignedString(int i) MethodThe toUnsignedString(int i) is an inbuilt method of Java which is used to return a string representation of the argument as an unsigned decimal value. 2. Java Integer toUnsignedString(int i, int radix) MethodThis method returns a string representation of the first int type argument as an unsigned integer value in the radix specified by the second argument. If the radix is smaller than Character.MIN_RADIX or larger than Character.MAX_RADIX then the base 10 is used. In this method, the following ASCII characters are used as digits: 0 to 9 and a to z. Note: Here, the first argument is treated as an unsigned value so, there is no leading sign character will be printed.Syntax:Following is the declarations of toUnsignedString() method: Parameter:
Returns:
Exceptions:NA Compatibility Version:Java 1.8 and above Example 1Test it NowOutput: String Representation = 25 String Representation = 4294967278 Example 2Output: Enter Value: ABCD Exception in thread "main" java.util.InputMismatchException at java.base/java.util.Scanner.throwFor(Scanner.java:939) at java.base/java.util.Scanner.next(Scanner.java:1594) at java.base/java.util.Scanner.nextInt(Scanner.java:2258) at java.base/java.util.Scanner.nextInt(Scanner.java:2212) at myPackage.IntegerToUnsignedStringExample2.main(IntegerToUnsignedStringExample2.java:9) Example 3Test it NowOutput: String Value = 4294967231 String Value = 41 String Value = ffffffbf String Value = 1000001 String Value = 11111111111111111111111110111111 Example 4Output: Enter Number: -37245327 Enter Radix/Base: 16 Output: fdc7ae71
Next TopictoUnsignedLong() Method
|