android - Java boolean return if statement -
this question has answer here:
- ternary operators java 6 answers
can please explain, in simple english, logic behind statement?
return mcontainsloadingrow ? (getcontentdatasize() + 1) : getcontentdatasize();
assuming mcontainsloadingrow boolean, if mcontainsloadingrow
true
,
then return getcontentdatasize() + 1
.
if not, return getcontentdatasize()
.
is correct way @ this?
this complete expression know as ternary operator in java
.
code statement
mcontainsloadingrow ? (getcontentdatasize() + 1) : getcontentdatasize(); || || || //boolean expression //return if true //return if false
here in code
mcontainsloadingrow
boolean variable contains either true
or false
. can change mcontainsloadingrow
boolean expression (a>b or b==a or b <= etc.)
? (question mark)
:- enables fine whether true or false.
if true
expression (getcontentdatasize() + 1)
return.
if false
expressin getcontentdatasize()
value return.
Comments
Post a Comment