Java.lang.Long.getLong(String nm) 方法
描述
java.lang.Long.getLong(String nm)方法判断指定名称的系统属性的long值。如果没有指定名称的属性,如果指定名称为空或 null,或者如果属性没有正确的数字格式,则返回 null。
声明
以下是 java.lang.Long.getLong() 方法的声明。
public static Long getLong(String nm)
参数
nm − 这是属性名称。
返回值
该方法返回属性的 Long 值。
异常
NA
示例
下面的例子展示了 java.lang.Long.getLong() 方法的使用。
package com.tutorialspoint;
import java.lang.*;
public class LongDemo {
public static void main(String[] args) {
// determines the Long value of the system property
String str = "sun.arch.data.model";
System.out.println(Long.getLong(str));
// prints null
str = "lang";
System.out.println(Long.getLong(str));
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
64 null

