Java Integer toUnsignedLong() method
The toUnsignedLong() method of Java Integer class returns a long value by simply converting the given argument to long after an unsigned conversion. Syntax public static long toUnsignedLong (int x) Parameters The parameter ‘x’ represents an integer to be converted to an unsigned long. Return Value This method returns the long value after an unsigned conversion. Example 1
public class JavaIntegerToUnsignedLongExample1 { public static void main(String[] args) { Integer val1=76; //It returns the long value after an unsigned conversion Long l1=Integer.toUnsignedLong(val1); System.out.println("Long value : "+l1); } }Output
Long value : 76Example 2
public class JavaIntegerToUnsignedLongExample2 { public static void main(String[] args) { Integer val1=76; Integer val2=98; //It returns the long value after an unsigned conversion Long l1=Integer.toUnsignedLong(val1); Long l2=Integer.toUnsignedLong(val2); //calling Long class methods Long sum=Long.sum(l1,l2); System.out.println("Sum of "+l1+" and "+l2+" : "+sum); } }Output
Sum of 76 and 98 : 174