Yes. Comparison gives a logical value and can be assigned to a variable in the same way as any other value.
The second form (with ternary operator ?:) is redundant and should not be used.
Stylistically, I usually enclose logical expressions in parentheses when assigning values to them, since
boolean bool = (aString.indexOf(subString) != -1);
to make a strong visual distinction between two statements using a symbol =, but this is not required.