Why is the below line not giving a compile time error?
StringBuffer sb = new StringBuffer(new StringBuffer());
I did enough online search but couldn't find the reason. Not just this it is also allowing StringBuider argument
StringBuffer sb2 = new StringBuffer(new StringBuilder());
Someone please help me.
Because StringBuffer
and StringBuilder
implements the interface CharSequence
and the StringBuffer
has a constructor for that interface.