• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

Difference between additive & assignment operator

 
Ranch Hand
Posts: 137
Hibernate Netbeans IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are there any difference between additive and assignment operator.

When i say and , are they result same values?
 
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. They are equivalent.
 
Sidharth Pallai
Ranch Hand
Posts: 137
Hibernate Netbeans IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Patricia Samuel wrote:Yes. They are equivalent.



Even i thought they are same, until i came across below
One provides implicit casting and the other not.

For Eg.

 
Sheriff
Posts: 22037
108
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"x += y" is roughly the same as "x = (type)(x + y)" where "type" is one of byte, char, short, int, etc. This implicit cast is what causes "x += 1" to compile and "x = x + 1" to not compile - the result of any arithmetic operation is never byte, char or short.
 
Patricia Samuel
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

are they result same values?



And i guessed you are asking in the terms of result. There is no doubt left. Rob has cleared the thing now.
 
Marshal
Posts: 70998
291
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try it carefully.
 
Bring out your dead! Or a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic