when writing these lines @ class level
int a; a=5;
it giving me error : "identifier expected"
and when m declaring local variable , writing like
void m1() { int a; a=5; }
no error . why ?
when you're doing @ class level, you're allowed combine declaration , assignment in one statement, like:
class { int = 5; }
otherwise, have wrap assignment withing block (constructor, method, initializer block). example:
class { int a; public a() { = 5; } //via constructor void seta() { = 5; } //via method { = 5; } //via initializer block }