Java 泛型集合与方法:原理、应用与实现
1. 泛型集合基础
1.1 Properties 类
Properties 对象是持久化的 Hashtable,通常用于存储字符串键值对。可以使用 setProperty 和 getProperty 方法来操作,而不是继承自 Hashtable 的 put 和 get 方法。以下是具体操作示例:
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.Set;
public class PropertiesTest
{
public static void main( String[] args )
{
Properties table = new Properties(); // 创建 Properties 表
// 设置属性
table.setProperty( "color", "blue" );
table.setProperty( "width", "200" );
// 替换属性值
table.setProperty( "color", "red" );
System.out.println( "A
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



