• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

polymorphism

 
vishnu hiranamayee
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all ,
please let me know the difference between "+=" and "=+" and which one is the best one to go for.




Thanks in advance
Vishnu
 
Petrus Pelser
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

If you use '+=', you can concatenate strings or accumulate a total.

If you use '=+' it has the same effect as '='. The '+' is then evaluated on its own.

There is no '=+' op.
 
vishnu hiranamayee
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use '=+' it has the same effect as '='. The '+' is then evaluated on its own.

There is no '=+' op.


i did't get what u were trying to explain
 
Petrus Pelser
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no '=+' operator in java. In an expression, the right-hand side is evaluated first. Thus if you have an expression:
ans =+ 5;
then it is the same as:
ans =(+ 5);
which is:
ans = 5;

If you have an expression:
ans += 5;
then it is the same as:
ans = ans + 5;

Hope this is clearer.
 
vishnu hiranamayee
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Petrus Pelser,


thanks for ur reply .
so =+ and += are no way related to polymorphism?
correct?

Regards ,
Vishnu.
 
Pran Pal
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, they are not related to polymorphism.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic