aspose file tools*
The moose likes Beginning Java and the fly likes OP= Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "OP=" Watch "OP=" New topic
Author

OP=

Buddhi Vikasitha
Greenhorn

Joined: Nov 01, 2012
Posts: 17



I'm confused with this operational assignment and I need to know how will this one execute and what will the result be? Beginner... thanks.
Stuie Clarky
Ranch Hand

Joined: Nov 09, 2012
Posts: 73

+= adds the right variable to the left variable, and stores the result in the left variable, e.g a=1, b=2, a+=b would result in a=3. The * works in a similar fashion, except it multiples instead. In this example you can follow it through in your head and then see if what you get is the same as what the output of 'a' is.


OCAJP 7
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Buddhi Vikasitha wrote:I need to know how will this one execute and what will the result be? Beginner... thanks.


Wheras Stuie gave you the basics on how the operators work, your question is a bit more complicated because of the type conversions. The best way to see how it executes and what the result will be would be to run it. What do you get? Then try to break the key line:

into smaller sequential parts to see if you can find out what each step does.


Steve
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Steve Luke wrote:
Wheras Stuie gave you the basics on how the operators work, your question is a bit more complicated because of the type conversions. The best way to see how it executes and what the result will be would be to run it. What do you get? Then try to break the key line:

into smaller sequential parts to see if you can find out what each step does.



Also, it may help to know that all compound assignment operators have the same precedence -- and have right to left associativity.

Henry

Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OP=