java system类_Java System类clearProperty()方法及示例

java system类

系统类clearProperty()方法 (System class clearProperty() method)

  • clearProperty() method is available in java.lang package.

    clearProperty()方法在java.lang包中可用。

  • clearProperty() method is used to remove or clear the property value denoted by the given argument (property_name).

    clearProperty()方法用于删除或清除由给定参数(property_name)表示的属性值。

  • clearProperty() method is static so this method is accessible with the class name too.

    clearProperty()方法是静态的,因此也可以使用类名访问此方法。

  • clearProperty() method may be thrown various type of exception and the exception are given below:

    clearProperty()方法可能会引发各种类型的异常,该异常如下所示:

    • SecurityException: If a particular method checkPropertyAcess() does not allow access to the given system property in the method.SecurityException:如果特定方法checkPropertyAcess()不允许访问该方法中的给定系统属性。
    • NullPointerException: If the given system property is null.NullPointerException:如果给定的系统属性为null。
    • IllegalArgumentException: If the given system property value is empty.IllegalArgumentException:如果给定的系统属性值为空。

Syntax:

句法:

    public static String clearProperty(String property);

Parameter(s):

参数:

  • property – represents the name of the property to be removed.

    property –表示要删除的属性的名称。

Return value:

返回值:

The return type of this method is String, it returns the old string value of the System property and if there is no property value with that "property_name", it returns null.

此方法的返回类型为String ,它返回System属性的旧字符串值,如果没有带有该“ property_name”的属性值,则返回null。

Example:

例:

// Java program to demonstrate the example of 
// clearProperty() method of System Class.

public class ClearPropertyMethod {
    public static void main(String[] args) {
        // By using  getProperty() method is used 
        // to get the value of the property
        System.out.println(System.getProperty("user.name"));

        // By using  clearProperty() method is used to 
        // clear the value of the property
        System.clearProperty("user.name");

        // Display the value of the property
        System.out.println("After clearProperty()...");
        System.out.println(System.getProperty("user.name"));
    }
}

Output

输出量

E:\Programs>javac ClearPropertyMethod.java
E:\Programs>java ClearPropertyMethod
root
After clearProperty()...
null


翻译自: https://www.includehelp.com/java/system-class-clearproperty-method-with-example.aspx

java system类

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值