Java java.lang Boolean getBoolean(String name)
Description Of Boolean: getBoolean(String name)
The java.lang.Boolean.getBoolean(String name) returns true if and only if the system property named by the argument exists and is equal to the string "true". A system property is accessible through getProperty, a method defined by the System class.
If there is no property with the specified name, or if the specified name is empty or null, then false is returned.
Boolean.getBoolean(String name) method returns the boolean value of the system property.
Code Example Java Boolean
public class BooleanExam {
public static void main(String[] args) {
boolean bool1, bool2;
System.setProperty("demo1", "true");
System.setProperty("demo2", "abcd");
String s1 = System.getProperty("demo1");
String s2 = System.getProperty("demo2");
bool1 = Boolean.getBoolean("demo1");
bool2 = Boolean.getBoolean("demo2");
String str1 = "boolean value of system property demo1 is " + bool1;
String str2 = "System property value of demo1 is " + s1;
String str3 = "boolean value of system property demo2 is " + bool2;
String str4 = "System property value of demo2 is " + s2;
System.out.println(str1);
System.out.println(str2);
System.out.println(str3);
System.out.println(str4);
}
}
ไม่มีความคิดเห็น :
แสดงความคิดเห็น