[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
Solved

Posted on 2006-04-23
Medium Priority
3,391 Views

if(y % 2 == 1)
system.out.println(a);
0
Question by:kitcoop

LVL 6

Expert Comment

ID: 16522286
Hi ,

y % 2 results in remainder after dividing y by 2

cheers
0

LVL 10

Expert Comment

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

It represents a modular (Remainder) operator.

Cheers!
0

LVL 16

Expert Comment

ID: 16522382
0

LVL 24

Expert Comment

ID: 16522423
% has the same meaning in ALL JAVA versions!

;JOOP!
0

LVL 30

Expert Comment

ID: 16522457
yeah and it has not been changed since C, C++ ;-)
0

LVL 86

Expert Comment

ID: 16523188
In that case it means 'if y is an odd number'
0

LVL 3

Accepted Solution

modsiw earned 2000 total points
ID: 16524932
In that case it means 'if y is an odd number'

Actually it means if y is an odd number greater than 0.

-3 % 2 = -1

if(y % 2 != 0)   is a better 'if y is an odd number' statement.
0

LVL 86

Expert Comment

ID: 16525042
Yes
0

LVL 3

Expert Comment

ID: 16549939
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)
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correctā¦
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Javaā¦