You are in luck as the most obvious approach is also the fastest: a boolean
variable. As an example, consider a slightly more involved boolean expression like the following:
c = a && b || o != null && o.equals(p)
where a
, b
, and c
are your "boolean" variables and try rewriting that for the case where you are using int
for boolean. You'll see that you are forced to introduce quite a bit more logic, potentially hurting performance and definitely hurting readability.
On a general note, unless you do nothing else but operations on primitive types in your complete codebase, you shall never be able to observe the difference in the various choices you are considering (except maybe for the string approach).