# is my understanding of the remainder operator correct?

posted 5 years ago

I'm reading the operators chapter in the SCJP book and just want to confirm that my understanding of this operator is correct.

Means, 3 can fit into 10 3 times, and we are left with 1. therefore y will be 1

z = 2 because 4 fits into 10 twice, and leaves a remainder of 2?

I couldn't find a better way of explaining it, but is this correct?

Means, 3 can fit into 10 3 times, and we are left with 1. therefore y will be 1

z = 2 because 4 fits into 10 twice, and leaves a remainder of 2?

I couldn't find a better way of explaining it, but is this correct?

Kind Regards, James. OCPJP 1.6 || My SCJP / OCJCP Study Notes

Interested in : SCJP, Google App Engine, Stripes, Android;|| My Bite-Size SCJP Study Blog

posted 5 years ago

But take care when using negative numbers. Is -10 % 4 2, or is it -2? And what about 10 % -4 and -10 % -4? (Hint: try it out)

SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6

How To Ask Questions How To Answer Questions