Java long getLong(String nm) method example

HQ » Java Tutorial » java.lang » Long » getLong(String nm)
Java long getLong(String nm) method example 2018-02-16T07:26:14+00:00

java.lang.Long getLong(String nm)

Description

The Long.getLong(String nm) java method determines the long value of the system property with the specified name.

The first argument is treated as the name of a system property. System properties are accessible through the System.getProperty(java.lang.String) method. The string value of this property is then interpreted as a long value using the grammar supported by decode and a Long object representing this value is returned.

If there is no property with the specified name, if the specified name is empty or null, or if the property does not have the correct numeric format, then null is returned.

In other words, this method returns a Long object equal to the value of:

getLong(nm, null)

Make a note that the getLong(String nm) 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.getLong(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 compare method non statically.

Notes:

  • This method throws SecurityException, for the same reasons as System.getProperty.

Method Syntax

public static Long getLong(String nm)

Method Argument

Data Type Parameter Description
String nm property name.

Method Returns

The getLong(String nm) method of Long class returns the Long value of the property.

Compatibility

Requires Java 1.0 and up

Java Long getLong(String nm) Example

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

Sample Output

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

Java Long getLong(String nm) 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