欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

java中properties作用,java中Properties有什么用,举例说明?

发布时间:2024/1/23 编程问答 53 豆豆
生活随笔 收集整理的这篇文章主要介绍了 java中properties作用,java中Properties有什么用,举例说明? 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

马克-to-win:Properties里面存着也是键值对,而且它更方便java对配置文件,字符串的操作,

例:3.9.1

import java.util.*;

public class TestMark_to_win {

public static void main(String args[]) {

Properties sala = new Properties();

Set name;

String str;

sala.put("zs", "1111");

sala.put("ls", "2222");

sala.put("ww", "3333");

sala.put("zl", "4444");

// Show all name and sala in hashtable.

name = sala.keySet(); // get set-view of keys

Iterator itr = name.iterator();

while (itr.hasNext()) {

str = (String) itr.next();

System.out.println("The sala of " +

/* public String getProperty(String key)Searches for the property

* with the specified key in this property list.*/

str + " is " + sala.getProperty(str) + ".");

}

System.out.println();

// look for state not in list -- specify default

/*

* Searches for the property with the specified key in this property

* list. The method returns the default value argument if the property

* is not found.

*/

str = sala.getProperty("Mark", "Not Found");

System.out.println("The sal of Mark is " + str + ".");

}

}

结果:

。。。。。。。。。。。。。。。。。

详情黏贴以下网址在地址栏后请进:http://www.mark-to-win.com/JavaBeginner/JavaBeginner7_web.html#DefinitionUsageOfProperties

总结

以上是生活随笔为你收集整理的java中properties作用,java中Properties有什么用,举例说明?的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。