Page 1 of 1

About Question enthuware.ocajp.i.v8.2.862 :

Posted: Mon May 15, 2017 5:08 am
by Javier
Hello Paul!
I would like to ask a question, perhaps it is a little bit silly because my understanding in English is not really great.
with the statement,
d=d +1;
"This will not compile because Java does not allow operator overloading for user defined objects."
This means that we can not use operator overloading for created objects?
Thank you very much Paul

Re: About Question enthuware.ocajp.i.v8.2.862 :

Posted: Mon May 15, 2017 11:57 pm
by admin
Actually, you are right. The statement is not proper. It should say, "This will not compile because Java does not allow operator overloading for user defined classes."

Java overloads the + operator only for String class. It does not allow this operator to be used with any other class unless one of the operands is a String.

hope this helps and thank you for your feedback!
Paul.

Re: About Question enthuware.ocajp.i.v8.2.862 :

Posted: Tue May 16, 2017 6:31 am
by Javier
Thank you very much Paul!
I understand it much more clear now!