This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

StringBuffer  RSS feed

 
Yosi Hendarsjah
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anybody know why StringBuffer class doesn't override equals() and hashCode() methods?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably because it would make for confused programming.
Since the contents could be modified after storing the StringBuffer in a collection, the identity equals is what you want, not a content based one.
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!