if (maxValue = 100)
System.out.println ("Your limit has been reached");
?
Why is the above if statement illegal? How would you fix it?
What will be an ideal response?
A common programming error occurs when a programmer uses a single equal sign rather than a double equal sign when attempting to determine equivalency. The expressionmaxValue = 100does not comparemaxValueto 100. Instead, it attempts to assign the value 100 tomaxValue. When the expressionmaxValue = 100is used in theifstatement, the assignment is illegal because only Boolean expressions are allowed.?Then,ifstatement should be written as:
if(maxValue == 100)
System.out.println("Your limit has been reached");
You might also like to view...
A(n) ________ file uses tabs to separate data into columns that can be imported into Excel
Fill in the blank(s) with correct word
Which of the following would be used to identify terminations in a punch block for which the wiring diagram has been lost?
A. OTDR B. Protocol analyzer C. Toner probe D. TDR