bob leoanrdo wrote:Why local variables must be initialised before using them?
why they don't have default values?
way instance variables have default values?
This is because failure to initialize a local variable has been identified (by the constructors of the Java language) to be a common source of error. So even if Java easily could give local variables a default initial value and that this sometimes would be convenient, it doesn't. It requires you to actively consider what value the variable should have and take on full responisbility for a correct initialization. It really is to help you avoid errors.