toString(): This method is available in java.util.Properties class of Java.
Syntax:
String java.util.Properties.toString()
This method returns a string representation of this Hashtable object in the form of a set of entries, enclosed in braces and separated by the ASCII characters " , " (comma and space).
Parameters: NA
Returns: a string representation of this hashtable.
Exceptions: NA
Approach
Java
import java.util.Properties;public class PropertiestoString {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(properties.toString());}}
Output:
{Java=Program, C++=Program, Hello=World}
No comments:
Post a Comment