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 53777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:06:59+00:00 2026-05-10T17:06:59+00:00

Coming from C++ to Java, the obvious unanswered question is why didn’t Java include

  • 0

Coming from C++ to Java, the obvious unanswered question is why didn’t Java include operator overloading?

Isn’t Complex a, b, c; a = b + c; much simpler than Complex a, b, c; a = b.add(c);?

Is there a known reason for this, valid arguments for not allowing operator overloading? Is the reason arbitrary, or lost to time?

  • 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. 2026-05-10T17:07:00+00:00Added an answer on May 10, 2026 at 5:07 pm

    Assuming you wanted to overwrite the previous value of the object referred to by a, then a member function would have to be invoked.

    Complex a, b, c; // ... a = b.add(c); 

    In C++, this expression tells the compiler to create three (3) objects on the stack, perform addition, and copy the resultant value from the temporary object into the existing object a.

    However, in Java, operator= doesn’t perform value copy for reference types, and users can only create new reference types, not value types. So for a user-defined type named Complex, assignment means to copy a reference to an existing value.

    Consider instead:

    b.set(1, 0); // initialize to real number '1' a = b;  b.set(2, 0); assert( !a.equals(b) ); // this assertion will fail 

    In C++, this copies the value, so the comparison will result not-equal. In Java, operator= performs reference copy, so a and b are now referring to the same value. As a result, the comparison will produce ‘equal’, since the object will compare equal to itself.

    The difference between copies and references only adds to the confusion of operator overloading. As @Sebastian mentioned, Java and C# both have to deal with value and reference equality separately — operator+ would likely deal with values and objects, but operator= is already implemented to deal with references.

    In C++, you should only be dealing with one kind of comparison at a time, so it can be less confusing. For example, on Complex, operator= and operator== are both working on values — copying values and comparing values respectively.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer thanks for the replys everyone, this is what I came… May 11, 2026 at 10:08 pm
  • Editorial Team
    Editorial Team added an answer The easiest solution is to copy and paste. WHERE upper(DECODE(upper(Table.Column),… May 11, 2026 at 10:08 pm
  • Editorial Team
    Editorial Team added an answer You can do a shortcut using coalesce to concatenate a… May 11, 2026 at 10:08 pm

Related Questions

Coming from C++ to Java, the obvious unanswered question is why didn't Java include
I'm a Java rookie and I was wondering, if I have the following typical
I'm a relatively new Java programmer coming from C++/STL, and am looking for a
I have a good understanding of OO from java and C# and I'm lucky
Coming from a C++ background I have to master the complexity of the Java

Trending Tags

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

Top Members

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.