question archive Can a boolean variable equate itself? For example, if booleanVariable has been initialized as True, and we have a booleanMethod() checking whether something evaluates to true/false; would the second underlined statement be doing a comparison between the booleanVariable and the booleanMethod result and saving said result in booleanVariable? If so, why not just equate booleanVariable to the booleanMethod() itself? Example code: boolean booleanVariable = True; //initializing booleanVariable booleanVariable = booleanVariable && booleanMethod();
Subject:Computer SciencePrice:4.86 Bought7
Can a boolean variable equate itself?
For example, if booleanVariable has been initialized as True, and we have a booleanMethod() checking whether something evaluates to true/false; would the second underlined statement be doing a comparison between the booleanVariable and the booleanMethod result and saving said result in booleanVariable? If so, why not just equate booleanVariable to the booleanMethod() itself?
Example code:
boolean booleanVariable = True; //initializing booleanVariable
booleanVariable = booleanVariable && booleanMethod();
Purchased 7 times