Cloning an Object in Java
<p>I am trying to clone a DTO. I have taken a DTO Object as shown:</p>

<pre><code>public class Employee implements Cloneable 
{

    String name;
    String dept;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDept() {
        return dept;
    }

    public void setDept(String dept) {
        this.dept = dept;
    }

}
</code></pre>

<p>But this line is giving me Error :</p>

<pre><code>public class Test 
{

        public static void main(String args[]) {
        Employee emp1 = new Employee();
        emp1.setDept("10");
        emp1.setName("Kiran");
        Employee emp2 = (Employee) emp1.clone(); // This Line is giving error .


    }
}
</code></pre>

<p>My query is that clone method is from <code>Object</code>, so why can't we use it directly like we do the `toString Method?</p>
