Provide a declaration for i that turns this loop into an infinite loop:
while (i != i + 0) {
}
The inescapable conclusion is that the type of i must be non-numeric, and therein lies the solution. The only non-numeric type for which the + operator is defined is String. The + operator is overloaded: For the String type, it performs not addition but string concatenation. If one operand in the concatenation is of some type other than String, that operand is converted to a string prior to concatenation
No comments:
Post a Comment