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

x
?
Solved

meaning of percent sign in java SDK2.0

Posted on 2006-04-23
9
Medium Priority
?
3,391 Views
Last Modified: 2012-06-27
what does the percent sign in this code mean?

if(y % 2 == 1)
     system.out.println(a);
0
Comment
Question by:kitcoop
9 Comments
 
LVL 6

Expert Comment

by:avinthm
ID: 16522286
Hi ,

y % 2 results in remainder after dividing y by 2

cheers
0
 
LVL 10

Expert Comment

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

It represents a modular (Remainder) operator.

Cheers!
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 16522382
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 24

Expert Comment

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

;JOOP!
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16522457
yeah and it has not been changed since C, C++ ;-)
0
 
LVL 86

Expert Comment

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

Accepted Solution

by:
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

by:CEHJ
ID: 16525042
Yes
0
 
LVL 3

Expert Comment

by:modsiw
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month20 days, 14 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question