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)
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 : 4294961629Example 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 : zik0zjExample 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