Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Last edited by helloworld922; March 10th, 2012 at 01:28 PM. Reason: please use [code] tags
Please explain what you mean by "work".
Does the code compile and execute?
What is printed out when the code is executed?
Most of the code is very simple.
What line(s) of the code are a problem for you?
Do you know about the tertiary operator? The ? and :
It is like an if else statement in a small method:
if(row %2 == 1) return "<" else return ">"
yes i do but i dont get this part ( row %2==1 ) i dont understand how does it run or work
% is the modulus/remainder operator.
To see how it works, write a small program with a loop and print out the values of the loop index when you use that operator. Something like this:
int var = 3;
for (int i=0;i,20;i++){
S.o.println(i %var);
}
Change the values of var to see what happens with different values