Showing posts with label access modifier. Show all posts
Showing posts with label access modifier. 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

Thursday, December 12, 2013

Published 12/12/2013 by with 0 comment

The constructor ... is not visible

When you invoke the private constructor of a class in another class, you’ll get the error message “The constructor ... is not visible”. And when the private constructor of a super class is invoked from the subclass implicitly or explicitly, you’ll get the following: Implicit super constructor ... is not visible for default constructor. Must define an explicit constructor. Implicit super constructor...
Read More
    email this       edit

Thursday, May 19, 2011

Published 5/19/2011 by with 2 comments

attempting to assign weaker access privileges

Java error "attempting to assign weaker access privileges" can happen when we override a superclass method in the subclass if the access modifier is not correctly chosen. See the sample code below: public class SuperClass { public void display() { System.out.println("this is super class"); } } public class Subclass extends SuperClass { private void display() { System.out.println("this...
Read More
    email this       edit
Published 5/19/2011 by with 4 comments

modifier private not allowed here

Java error "modifier private not allowed here" can occur for any of the following reasons: 1. An outer class declared as private like below: private class OuterClass {     //... }An outer class only be public or package private not private or protected. So you can write an outer class as below: public class OuterClass {    //... }or class OuterClass {    //... }This...
Read More
    email this       edit