could anyone please tell me why we can't assign a value to a previously declared (primitive || reference )variable inside a class body? but it is ok inside a method body as shown below
``Worry does not empty tomorrow of its sorrow; it empties today of its strength.''
You can only have declarations at that point in the code. Executable statements can go inside methods, as you say, or inside static initializer blocks or instance initializer blocks. Or inside constructors.
Paul Clapham wrote:You can only have declarations at that point in the code. Executable statements can go inside methods, as you say, or inside static initializer blocks or instance initializer blocks. Or inside constructors.
thanks for the quick reply Paul..
``Worry does not empty tomorrow of its sorrow; it empties today of its strength.''