I am looking through code and wondering what this means:
Boolean foo = request.getParameter("foo") == null? false:true;
It’s gotta be something that converts the returning String from getParameter() into a Boolean.
But I’ve never seen this kind of Java with a questionmark and colon (except in a foreach loop).
Any hel appreciated!
It’s the ternary operator. The snippet:
is equivalent to:
or (optimised):
The basic form of the operator is along the lines of: