clear(): This method is available in java.util.Properties class of Java.
Syntax:
void java.util.Properties.clear()
This method clears this hashtable so that it contains no keys.
Parameters: NA
Returns: NA
Exceptions: NA
Approach
Java
import java.util.Properties;public class Propertiesclear {public static void main(String[] args) {Properties properties = new Properties();properties.put("Hello", "World");properties.put("C++", "Program");properties.put("Java", "Program");System.out.println("Before clear " + properties);properties.clear();System.out.println("After clear " + properties);}}
Output:
Before clear {Java=Program, C++=Program, Hello=World}
After clear {}
No comments:
Post a Comment