Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 539045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:05:43+00:00 2026-05-13T10:05:43+00:00

StringBuffer sb1 = new StringBuffer(Java); StringBuffer sb2 = new StringBuffer(Java); System.out.println(sb1 == sb2); System.out.println(sb1.equals(sb2));

  • 0
StringBuffer sb1 = new StringBuffer("Java");
StringBuffer sb2 = new StringBuffer("Java");
System.out.println(sb1 == sb2);
System.out.println(sb1.equals(sb2));

Here both are returning false. How is it possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:05:43+00:00Added an answer on May 13, 2026 at 10:05 am

    The equals method of StringBuffer is not overridden from Object, so it is just reference equality, i.e., the same as using ==. I suspect the reason for this is that StringBuffer is modifiable, and overriding equals is mostly useful for value-like classes that you might want to use as keys (though lists also have an overridden equals and StringBuffer is kind of a list, so this is a bit inconsistent).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 488k
  • Answers 488k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It sounds like your web server may need to have… May 16, 2026 at 8:47 am
  • Editorial Team
    Editorial Team added an answer While the article isn't about the OAuth plugin (it's about… May 16, 2026 at 8:47 am
  • Editorial Team
    Editorial Team added an answer basename($str); May 16, 2026 at 8:47 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Why String.equls() returns true but Stringbuilder.equals() returns false? StringBuffer sb1 = new StringBuffer(Amit); StringBuffer
StringBuffer sb = new StringBuffer(abc); StringBuffer sb1 = sb; StringBuffer sb2 = new StringBuffer(abc);
Possible Duplicate: StringBuilder and StringBuffer in Java what is the difference between StringBuilder and
Possible Duplicate: How to get equivalent of ResultSetMetaData without ResultSet StringBuffer queryBuffer=new StringBuffer(SELECT *
Really simple question here (more to confirm my thoughts, than anything)... Java method: StringBuffer.Delete(start,end)
I'm using StringBuffer in Java to concat strings together, like so: StringBuffer str =
What is the difference between String and StringBuffer in Java? Is there a maximum
I'm currentlly refactoring an application using a lot of this: StringBuffer buff1 = new
Whenever I use equals() method with two different StringBuffer objects, I get the result
I think I understand StringIO somewhat as being similar to Java's StringBuffer class, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.