I think that both are false too. 1) == returns true if both are initialize with literals and both are identical literal strings. 2) The equals method isn�t implemented in StringBuffer
[This message has been edited by Marcela Blei (edited July 21, 2000).]
Joined: Nov 22, 2008
Are you sure about StringBuffer sb1="ab"; I guess it will not compile. The error will be incompatible type case. Yes StringBuffer did not override the equals() method and so it will not compare the contents. It will behave just like ==. Hope it helps!
Praveen, You an also create an empty StringBuffer using the StringBuffer() or StringBuffer( length ) constructors and use various flavours of append() methods to initialize it. ie., StringBuffer s = new StringBuffer("Hello") is same as
StringBuffer s = new StringBuffer() ; s.append("Hello"); Ajith
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).