hi,
both may look identical.The difference is that one of them is outside the method body and one is inside.
if you are required to write outside the method then make it in a single statement declaration and initialisation.This cannot be split.
the code below results in a compilation error:
class
Test {
int b;
b=10;
}
the code below results in a successfull compilation.
class Test {
int b=10;
public static void main(String args[]){
int b;
b=0;
}
}