You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public Object clone() throws CloneNotSupportedException //by implementing Cloneable interface
{
return super.clone();//for primitives like int,double the clone is making another object for it. But for non primitive it's not making a new one but it makes it point the same object but with different reference,this is called Shallow Copy.
}
}
public class Clone
{
public static void main(String[] args) throws CloneNotSupportedException
{
Scanner sc = new Scanner(System.in);
Student ab= new Student(1,89.45);
Student cb= new Student(ab);//this will take much longer time as its creating a new object