Showing posts with label Static. Show all posts
Showing posts with label Static. 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) {  ...
Read More
    email this       edit

Monday, May 9, 2011

Published 5/09/2011 by with 1 comment

modifier static not allowed here

Java error "modifier static not allowed here" can occur for any of the following reasons: 1. Constructor is declared as static(!) A constructor cannot be static. In the wrong code below: public class Person { private String firstName; private String lastName; public static Person() { //... } } Here the constructor Person is declared as static. As the constructor must be non-static, the...
Read More
    email this       edit
Published 5/09/2011 by with 1 comment

illegal combination of modifiers: abstract and static

An abstract method cannot be static because the abstract method must be overridden i.e, body of the abstract method must be defined before invocation. See the wrong code below: public abstract class Employee { public static abstract double earnings(); // error } Here the abstract method earnings() is declared as static. An abstract method must be non-static. So the correct code is: public abstract...
Read More
    email this       edit