Integer.toBinaryString switch string value?
Why does the following 'if()' statement evaluate to true?
operand1 = "0";
operand1 = Integer.toBinaryString(Long.valueOf(operand1, 10).intValue());
if(operand1 != "0") {
display_secondary.setText(operand1.toUpperCase(Locale.ENGLISH));
}
The 'if' statement above is evaluated to true and the code inside is run.
Why does that happen?
The code below evaluates to false.
operand1 = Integer.toBinaryString(Long.valueOf(operand1, 10).intValue());
operand1 = "0";
if(operand1 != "0") {
display_secondary.setText(operand1.toUpperCase(Locale.ENGLISH));
}
No comments:
Post a Comment