Is there a way to make Java work with boolean/integer addition and evaluation?
More specificly, C++ has an appropriate feature which shortens many if statements.
You can use ternary operator in Java for the same effect.
public class Main {
public static void main(String[] args) {
int x = 5, y = 10, count = 0;
count += x == y ? 1 : 0;
System.out.println(count);
x = 10;
count += x == y ? 1 : 0;
System.out.println(count);
}
}