属性类Properties

    科技2023-09-25  78

    目前只需掌握Properties属性类对象的相关方法即可Properties是一个Map集合,继承Hashtable,Properties的key和value都是String类型Properties被称为属性类对象.Properties是线程安全的。需要掌握Properties的存和取两个方法。 package collection; import java.util.Properties; public class PropertiesTest01 { public static void main(String[] args) { Properties pro = new Properties(); pro.setProperty("username","root"); pro.setProperty("password","123"); String username = pro.getProperty("username"); String password = pro.getProperty("password"); System.out.println(username);//root System.out.println(password);//123 } }
    Processed: 0.011, SQL: 9