Saturday, September 20, 2014

A local variable, i.e., method level variable or a parameter cannot be declared as static or public/private/protected.

So local variables must be declared without these modifiers.

For example, the following code is wrong:

    void methodA(static int param) {


    void methodB(private int param) {


    void methodC() {

        private static int methodVariable = 10;


To resolve the error, remove static and the access modifiers from the local variable declarations. Only the class level variables (declared outside of any method) can be declared with static and access modifiers.

If the above solutions do not work for you. Please comment below giving your code. I'll try to respond.
This is the most recent post.
Older Post


Post a Comment