int i = true & false ? 0 : 1; java code example Example: java cast bolean to int int result = myBooleanVar ? 1 : 0;