getboolean
布尔类getBoolean()方法 (Boolean class getBoolean() method)
getBoolean() method is available in java.lang package.
getBoolean()方法在java.lang包中可用。
getBoolean() method is used to return the system property in boolean values either true or false.
getBoolean()方法用于以布尔值true或false返回系统属性。
getBoolean() method is a static method, it is accessible with the class name too and if we try to access the method with the class object then also we will not get an error.
getBoolean()方法是一个静态方法,也可以使用类名进行访问,如果我们尝试使用类对象访问该方法,那么我们也不会收到错误。
getBoolean() method does not throw an exception at the time of returning system property.
getBoolean()方法在返回系统属性时不会引发异常。
Syntax:
句法:
1
2
3public static boolean getBoolean(String sys_prop);
Parameter(s):
参数:
String sys_prop – represents the string value (system _property) to be parsed.
字符串sys_prop –表示要解析的字符串值(系统_property)。
Return value:
返回值:
The return type of this method is boolean - it returns the corresponding boolean value that represent the String value.
此方法的返回类型为boolean-它返回表示String值的相应布尔值。
Note: If the given argument system_property exists and the value is equal to true, it returns true.
注意:如果给定参数system_property存在并且值等于true ,则返回true 。
Example:
例:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19// Java program to demonstrate the example // of getBoolean(String sys_prop) method of Boolean class public class GetBooleanOfBooleanClass { public static void main(String[] args) { String sys_prop1 = "Is Java8 exists"; String sys_prop2 = "Is C++ not support OOPS"; // By setting property value by using // setProperty(propertyname , value) method System.setProperty(sys_prop1, "true"); System.setProperty(sys_prop2, "false"); // Store result in boolean variables boolean b1 = Boolean.getBoolean(sys_prop1); boolean b2 = Boolean.getBoolean(sys_prop2); // Display result System.out.println("Boolean.getBoolean(sys_prop1): " + b1); System.out.println("Boolean.getBoolean(sys_prop2): " + b2); } }
Output
输出量
1
2
3Boolean.getBoolean(sys_prop1): true Boolean.getBoolean(sys_prop2): false
翻译自: https://www.includehelp.com/java/boolean-class-getboolean-method-with-example.aspx
getboolean
最后
以上就是有魅力自行车最近收集整理的关于getboolean_Java布尔类getBoolean()方法及示例的全部内容,更多相关getboolean_Java布尔类getBoolean()方法及示例内容请搜索靠谱客的其他文章。
发表评论 取消回复