Just want to know if there is a difference between Java:
private boolean someValue; private boolean someValue = false;
Perhaps the second line is just a pause in time?
EDIT (SUMMARY):
From the answers I found that there is almost no difference, but:
"However, relying on such defaults is generally considered a bad programming style."
But there are some good reasons not to do this - see the accepted answer below.
EDIT 2
I found that in some cases the boolean value must be initialized, otherwise the code will not compile :
boolean someValue; if (someValue) {
In my NetBeans IDE, I got an error - "someValue variable may not have been initialized."
This is getting interesting .. :)
java boolean
Ernestas gruodis
source share