Java Long parseUnsignedLong(String s) method example

HQ » Java Tutorial » java.lang » Long » parseUnsignedLong(String s)
Java Long parseUnsignedLong(String s) method example 2018-02-16T07:26:12+00:00

java.lang.Long parseUnsignedLong(String s))

Description

The Long.parseUnsignedLong(String s) java method Compares two long values numerically. Parses the string argument as an unsigned decimal long. The characters in the string must all be decimal digits, except that the first character may be an an ASCII plus sign ‘+’ (‘\u002B’). The resulting integer value is returned, exactly as if the argument and the radix 10 were given as arguments to the parseUnsignedLong(java.lang.String, int) method.

Make a note that the parseUnsignedLong(String s) method of Long class is static thus it should be accessed statically which means the we would be calling this method in this format:

Long.parseUnsignedLong(method args)

Non static method is usually called by just declaring method_name(argument) however in this case since the method is static, it should be called by appending the class name as suffix. We will be encountering a compilation problem if we call the java parseUnsignedLong method non statically.

Notes:

  • This method will throw NumberFormatException, if the string does not contain a parsable unsigned integer.

Method Syntax

public static long parseUnsignedLong(String s) throws NumberFormatException

Method Argument

Data Type Parameter Description
String s a String containing the unsigned long representation to be parsed

Method Returns

The parseUnsignedLong(String s) method of Long class returns the unsigned long value represented by the decimal string argument.

Compatibility

Requires Java 1.8 and up

Java Long parseUnsignedLong(String s) Example

Below is a simple java example on the usage of parseUnsignedLong(String s) method of Long class.

Sample Output

Below is the sample output when you run the above example.

Java Long parseUnsignedLong(String s) example output

Contact Info

Singapore

Our Goal

JavaTutorialHQ aims to to be The Ultimate Guide on Java with hundreds of examples from basic to advance Topics.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close