can somebody tell me how does this code work i can get it
Printable View
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