boolean isComplete = true; sets a boolean value to true.
You seem to be having trouble with the idea of a boolean. To fix this, imagine a simple on/off lightswitch. If that lightswitch controlled a boolean statement, let’s call it
lightswitchstatus, then if it was in the on condition, it would be considered
true. If it is in the off condition, it would be considered
false. So if the value of
lightswitchstatus is true, then the light is on. If it is false, then the light is off.
Now that you have a basic understanding of boolean values, let’s look at your line.
boolean isComplete = true;
Let’s break down the statement.
boolean is declaring what type of variable this is. This tells us it is a boolean, or our “lightswitch” variable. It can either be on or off, true or false.
isComplete is the variable name. As with your name, it tells you what that value should be called. In your case, the “value” is you. When someone calls your name, you respond. Similarly, when someone calls our variable by its name, it knows to use that value in whatever you are telling it to do.
= is how you declare the variable. The variable name is equal to the value of the variable, so if I said
integer two = 2; the variable
two would be set to two.
; is the execution. You need this on all statements in Java. This shows the end of a statement. If you don’t have this, your code will error.
So in plain English, your statement tells your program the following:
There is a boolean value called isComplete that is set to the value true. (On Lightswitch)
I hope this helped you learn boolean variables, and with your question. If you need more help, I’d be happy to help, just tag me. Good luck.