java属性setproperty()方法与示例 -金沙1005

java属性setproperty()方法与示例属性类setproperty()方法(propertiesclasssetproperty()method)setproperty()methodisavailableinjava.utilpackage.setproperty()方法在java.util包中可用。setproperty()methodisusedtosetthegivenvaluee…

属性类setproperty()方法 (properties class setproperty() method)

  • setproperty() method is available in java.util package.

    setproperty()方法在java.util包中可用。

  • setproperty() method is used to set the given value element (val_ele) associated with the given key element (key_ele) when no value element associate previously otherwise it replaces the old value with the given value for the given key of this properties.

    setproperty()方法用于设置与给定键元素(key_ele)关联的给定值元素(val_ele),前提是之前没有关联的值元素,否则它将用此属性的给定键的给定值替换旧值。

  • setproperty() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    setproperty()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • setproperty() method does not throw an exception at the time of setting the property.

    setproperty()方法在设置属性时不会引发异常。

syntax:

句法:

    public object setproperty(string key_ele, string val_ele);

java属性setproperty()方法与示例

为防止网络爬虫,请关注公众号回复”口令”

激活idea 激活clion
datagrip dataspell
dotcover dotmemory
dottrace goland
phpstorm pycharm
resharper reshac
rider rubymine
webstorm 全家桶

parameter(s):

参数:

  • string key_ele – represents the key element at which the value is to be set.

    字符串key_ele –表示要在其上设置值的键元素。

  • string val_ele – represents the value element for the given key.

    字符串val_ele –表示给定键的value元素。

return value:

返回值:

the return type of the method is object, it returns the old value linked with the given key if exists otherwise it returns null.

方法的返回类型为object ,如果存在则返回与给定键链接的旧值,否则返回null。

example:

例:

// java program to demonstrate the example 
// of object setproperty(string key_ele, string val_ele)
// method of properties
import java.io.*;
import java.util.*;
public class setpropertyofproperties {
   
   
 public static void main(string arg[]) throws exception {
   
   
  // instantiate properties object
  properties prop = new properties();
  prop.put("10", "c");
  prop.put("20", "c  ");
  prop.put("30", "java");
  prop.put("40", "php");
  prop.put("50", "sfdc");
  // by using setproperty() method is to
  // replace the old value for the given
  // key if exists with the given new value
  object ob = prop.setproperty("20", "oops");
  // display old value returned for the
  // given key element
  system.out.println("prop.setproperty(20,oops): "   ob);
  // display updated list
  prop.list(system.out);
 }
}

output

输出量

prop.setproperty(20,oops): c  
-- listing properties --
50=sfdc
40=php
30=java
20=oops
10=c

翻译自:

js555888金沙老品牌的版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由思创斯整理,转载请注明出处:https://ispacesoft.com/141554.html

(0)

相关推荐

  • java 过滤器调用链_filterchain(过滤器链)详解「建议收藏」在一个web应用程序中可以注册多个filter程序,每个filter程序都可以针对某一个url进行拦截。如果多个filter程序都对同一个url进行拦截,那么这些filter就会组成一个filter链(也称过滤器链)。filter链用filterchain对象表示,filterchain对象中有一个dofilter()方法,该方法的作用是让filter…

  • java自定义异常类_java如何自定义异常为什么要自定义异常类?当我们在输入成绩,输入工资,取款的时候,往往都有一个范围,而这个范围不是jvm能够识别的,因此在输入的时候就容易出错,因此在这些时候jdk中的异常无法满足我们的需求,我们只能自己定义异常类。如何自定义异常类?可以通过继承exception来派生自己的子异常类。而exception中常用的构造方法: exception(), exception(message:string),…

  • java读取文件内容换行_append换行importjava.io.bufferedreader;importjava.io.filenotfoundexception;importjava.io.filereader;importjava.io.ioexception;publicclassread_1{staticstringbuildersb=newstringbuilder(); s

  • java 利用枚举实现单例模式的方法_什么是单例设计模式引言单例模式比较常见的实现方法有懒汉模式,dcl模式公有静态成员等,从java1.5版本起,单元素枚举实现单例模式成为最佳的方法。java枚举基本用法枚举的用法比较多,本文主要旨在介绍利用枚举实现单例模式的原理,所以这里也主要介绍一些相关的基础内容。首先,枚举类似类,一个枚举可以拥有成员变量,成员方法,构造方法。先来看枚举最基本的用法:enumtype{a,b,c,d;}创建en

  • linux停止jar包的运行_怎么运行java程序
    问题:在inux上通过shell终端运行启动时,执行命令:“java -jar xxx.jar”,当我们退出终端的时候,xxx.jar会停止运行, 原因:因为“java -jar xxx.jar”并没有以守护进程形式在linux后台自动运行; 金沙1005的解决方案:守护进程运行“java -jar xxx.ja …

  • java读取excel表的数据package com.shine.eiuop.utils; import org.apache.poi.ss.usermodel.*; import org.apache.poi.hssf.usermodel.hssfcell;import org.apache.poi.ss.usermodel. …

  • 数据库各种锁_数据库索引有哪几种索引和锁在数据库中可以说是非常重要的知识点了,在面试中也会经常会被问到的。 表经常进行insert/update/delete操作就不要建立索引了,换言之:索引会降低插入、删除、修改等维护任务的速度。 索引需要占物理和数据空间。 为什么说索引会降低插入、删除、修改等维护任务的速…

  • java switch 使用枚举类[亲测有效]开发过程中为了代码的可阅读性和可维护性,很多类型字段往往会习惯使用枚举去定义,可是在一些判断里面想用switch去代替ifelse就会出现以下问题publicenumsextype{man(1,”男”),girl(2,”女”),;privateinttype;privatestringwork;sextype(inttype,stringwork){this.type=type;

发表回复

您的电子邮箱地址不会被公开。

联系金沙1005

关注“java架构师必看”公众号

回复4,添加站长微信。

附言:ispacesoft.com网而来。

关注微信
网站地图