File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes %= operator? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "%= operator?" Watch "%= operator?" New topic
Author

%= operator?

Randy Trover
Ranch Hand

Joined: Feb 26, 2001
Posts: 34
Hi all,
I know the mod operator is %, but what does the %= do? Thanks for any help.
Cheers
Randy
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
a %= b is the same as
a = a % b;
where you stuff the result back into the a value that you started with.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Works just like '+=', '-=', and all the other math shortcut operators...



Both have the same effect... they assign the modulus of someNum and 5 to someNum...

HTH,
-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
Don't get me started about those stupid light bulbs.
 
subject: %= operator?