Link to home
Start Free TrialLog in
Avatar of kitcoop
kitcoop

asked on

meaning of percent sign in java SDK2.0

what does the percent sign in this code mean?

if(y % 2 == 1)
     system.out.println(a);
Avatar of avinthm
avinthm

Hi ,

y % 2 results in remainder after dividing y by 2

cheers
Hi kitcoop,
> if(y % 2 == 1)
>      system.out.println(a);

It represents a modular (Remainder) operator.

Cheers!
% has the same meaning in ALL JAVA versions!

;JOOP!
Avatar of Mayank S
yeah and it has not been changed since C, C++ ;-)
In that case it means 'if y is an odd number'
ASKER CERTIFIED SOLUTION
Avatar of modsiw
modsiw

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes
The comments by avinthm, sys_prog, suprapto45, and CEHJ contain correct answers to this question. The points should probably be reawarded or split.


Thanks much.

(also, this really wasn't worth 500pts)