android - Java boolean return if statement -


this question has answer here:

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

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -