Java source code examples

Java source code samples. Java code examples.

Checks a System property value is true or not.

          0 votes

To check a System property has a value true or not we can use the Boolean wrapper class.

public class BooleanWrapper {
	public static void main(String[] args) {
		boolean bool = Boolean.getBoolean("os.name");

		System.out.println(bool);
	}
}

This would return true only if the System property exist and has a value equal to true. All other cases this would return false.

Tags: java.lang

Discuss This Code