bool to int java code example Example 1: java cast bolean to int int result = myBooleanVar ? 1 : 0; Example 2: convert boolean to int int val = (bool) ? 1 : 0;