Properties clone() in Java

clone(): This method is available in java.util.Properties class of Java.

Syntax:

Object java.util.Properties.clone()

This method creates a shallow copy of this hashtable. All the structure of the hashtable itself is copied, but the keys and values are not cloned.

Parameters: NA

Returns: a clone of the hashtable.

Exceptions: NA

Approach

Java

import java.util.Properties;

public class Propertiesclone {
    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.clone());
    }
}

Output:

{Java=Program, C++=Program, Hello=World}


No comments:

Post a Comment