Dave's Brain

Browse - Programming Tips - Why am I getting this error from javac: error: illegal combination of modifiers: public and private

Date: 2013jan5
Language: Java

Q.  Why am I getting this error from javac: error: illegal combination of modifiers: public and private

A.  Everything in an interface must be public.  So this code
will get that error:

interface Test { private class Hello { // ERROR: things inside an interface cannot be private int abc; } }
This is a (minor) flaw in the language if you ask me. You might consider using a class instead of an interface.

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.