File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "%= operator?" Watch "%= operator?" New topic

%= 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.
Cindy Glass
"The Hood"

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

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...


Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: %= operator?
It's not a secret anymore!