11:37 am - Wednesday May 24, 2017

Properties example program using Object setProperty(String key, String value)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK

This Properties example program Calls the Hashtable method put using Object setProperty(String key, String value) method

Example Program


import java.util.*;

import java.io.*;

public class PropSetprop {

public static void main(String[] args) {

Properties prop = new Properties();

prop.put("hai", "welcome");

prop.put("SAkthi", "canning");

System.out.println(prop);

Properties prop1 = new Properties();

prop1.setProperty("hai", "welcome");

prop1.setProperty("Sakthi", "canning");

System.out.println(prop1);

}

}

 

Output

{SAkthi=canning, hai=welcome}

{hai=welcome, Sakthi=canning}

Explanation

public Object setProperty(String key,String value)

Calls the Hashtable method put. Provided for parallelism with the getProperty method. Enforces use of strings for property keys and values. The value returned is the result of the Hashtable call to put.

 

Parameters:

key – the key to be placed into this property list.

value – the value corresponding to key.

 

Returns:

the previous value of the specified key in this property list, or null if it did not have one.

 

Since:

1.2

 

See Also:

getProperty(java.lang.String)

BACK

Filed in: Z-A All Java Codes

Comments are closed.