I'm trying to understand variable declarations in Java.
Actually, I'm trying to understand why you would not declare variables at the top of class, initiate them, and then use as needed.
In the Headstart Java book it states local variables are declared within a method and initiated within the code block. I understand that aspect.
My question is, if you know the variable, why would you not declare it at the beggining of the method, instead of waiting and declaring/initializing in the middle of code?
Wouldn't that make code harder to read?
ex:
Class Foo {
while.... blah blah
int bar = 3 + dog.getsize();
}