System.setProperty(); - 简记

System.setProperty();

-- 源码记录
/**
     * Sets the system property indicated by the specified key.
     * <p>
     * First, if a security manager exists, its
     * <code>SecurityManager.checkPermission</code> method
     * is called with a <code>PropertyPermission(key, "write")</code>
     * permission. This may result in a SecurityException being thrown.
     * If no exception is thrown, the specified property is set to the given
     * value.
     * <p>
     *
     * @param      key   the name of the system property.
     * @param      value the value of the system property.
     * @return     the previous value of the system property,
     *             or <code>null</code> if it did not have one.
     *
     * @exception  SecurityException  if a security manager exists and its
     *             <code>checkPermission</code> method doesn't allow
     *             setting of the specified property.
     * @exception  NullPointerException if <code>key</code> or
     *             <code>value</code> is <code>null</code>.
     * @exception  IllegalArgumentException if <code>key</code> is empty.
     * @see        #getProperty
     * @see        java.lang.System#getProperty(java.lang.String)
     * @see        java.lang.System#getProperty(java.lang.String, java.lang.String)
     * @see        java.util.PropertyPermission
     * @see        SecurityManager#checkPermission
     * @since      1.2
     */

简单翻译一下:
这就类似map,key - value 对,放于内存中,获取的时候就用getProperty(“key”),
然后还有各种的exception 异常,注意查看


然后再来一段代码,简单看一下
好多"张三" 的代码实例,看腻了…
换一个口味

public static void main(String[] args) {
		//看一下,你的java运行时的版本
      System.out.println("你的Java运行时的版本 ==>>"+System.getProperty("java.runtime.version" ));
      //然后将你的java运行时版本修改,放心,只是展示变了
      System.setProperty("java.runtime.version", "helloWorld");
		//然后查看一下,修改之后的value
      System.out.println("修改之后的java运行版本值 ==>>"+System.getProperty("java.runtime.version" ));
   }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值