-
Strange java syntax
i have been programming java since 2 months and its ze first time that i have came across this ---
max = (i > j) ? i : j;
min = (i < j) ? i : j;
these are from a program THAT works but i don't undestand anything,google doesn't help at all and i have checked 1 e-book(1000 pages) ... nada
If any1 could help it would be great ... just explain whats going on here
-
Re: Strange java syntax
This is known as the ternary operator and is basically an if statement in disguise.
max = (i > j) ? i : j;
If i is greater than j assign i to max else assign j to max.
-
Re: Strange java syntax
Google 'java ternary operator'.
-
Re: Strange java syntax
thanks guys ... i guess 1 idiot out of the way ... lol