Showing posts with label Parameter. Show all posts
Showing posts with label Parameter. Show all posts

Saturday, September 20, 2014

Published 9/20/2014 by with 0 comment

Illegal modifier for parameter ... only final is permitted

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) {

        System.out.println(param);
    }

    void methodB(private int param) {

        System.out.println(param);
    }

    void methodC() {

        private static int methodVariable = 10;
        System.out.println(methodVariable);

    }


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.
Read More
    email this       edit