Properties.setProperty(String key, String value) has the following syntax.
public Object setProperty(String key, String value)
In the following code shows how to use Properties.setProperty(String key, String value) method.
import java.util.Properties; /*w w w. ja va 2 s . co m*/ public class Main { public static void main(String[] args) throws Exception { Properties prop = new Properties(); prop.setProperty("Chapter Count", "200"); prop.put("Tutorial Count", "1500"); prop.put("tutorial", "java2s.com"); // print the list System.out.println(prop); // change the properties prop.setProperty("Tutorial Count", "15"); prop.setProperty("Chapter Count", "500"); // print the list System.out.println(prop); } }
The code above generates the following result.