java - Why is it illegal to assign a class variable that was just declared? -
class { public int somevar; somevar = 123; /* cannot find symbol */ }
why cant language see variable declared? , unique java or true in classful oop languages?
in java, can declare instance variables inside class outside method, statements such somevar = 123;
must within method (or constructor, static initializer, or instance initializer).
Comments
Post a Comment