
please explain me the flow of this program..not able to execute correctly n wats the use of clone
public class Strclone {
public static void main(String args[]) { String s=new String("a"); String s1 = "Hello"; System.out.println(s1.length()); String s2 = "Hello";
String s3 = new String(s1);
String s4 =(String) s2.clone();
Object c=s.clone();
String b;
if(s==b)
{
System.out.println("true");
}
if(s.clone().equals(s))
{
System.out.println("equals");
}
}
}

String s=new String("a"); String s4 =(String) s2.clone();
here s4 that same object as s2.clone method is used for creating same object...
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.