Why String
class is not implementing Cloneable
interface?
For example: (We write this type of code sometimes.)
String s1 = new String("Hello");
String s2 = new String("Hello");
Here s1!=s2;
So instead of doing this , if we could have done:
String s1 = new String("Hello");
String s2 = s1.clone();
This could be easy.