Java Long - getLong() Method
The java.lang.Long.getLong() method is used to determine the long value of the system property with the specified name. The first argument is treated as the name of a system property.
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.
Syntax
public static Long getLong(String nm)
Parameters
nm |
Specify the property name. |
Return Value
Returns the Long value of the property.
Exception
Throws SecurityException, for the same reasons as System.getProperty.
Example:
In the example below, the java.lang.Long.getLong() method returns the Long value of the system property with the given name.
import java.lang.*; public class MyClass { public static void main(String[] args) { //creating system property using setProperty String x = "285"; System.setProperty(x, "285"); String y = "abc"; System.setProperty(y, "abc"); //printing the Long value of x System.out.print("The Long value of x is: "); System.out.println(Long.getLong(x)); //printing the Long value of y System.out.print("The Long value of y is: "); System.out.println(Long.getLong(y)); } }
The output of the above code will be:
The Long value of x is: 285 The Long value of y is: null
❮ Java.lang - Long