This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
A lot of times booleans are used as conditions in loops and if statements, you use your boolean an a condition in your if statement. If you never set canrecord to true, then you would never be able to record the tape in your example.
Another examples of boolean conditions is in a while loop:
"If the facts don't fit the theory, get new facts" --Albert Einstein
i know if i dont set it to true later on the dvd does not record . however why intially its initialized to false was something i was thinking about . Is the default not already false ?
Well i think i got the bigger picture though
Booleans in Java can be three values: true, false, or null.
You are correct in that booleans are initialized to false, but I think its good programming practice to initialize them as false.
What if someone whose background is in a different language is examining your code? they would have to guess at the initial value of the boolean.