Availability
Java 8 says:
All interface members without access modifiers are implicitly publicly
Java 7 says:
All interface members are implicitly public.
When I tried the following code:
public interface Test { protected int i = 10; }
And compiled, I got
Test.java data: error: modifier protected not allowed here protected int i = 10; ^
Java version: Java(TM) SE Runtime Environment (build 1.8.0-b129)
Java(TM) SE Runtime Environment (build 1.8.0-b129)
But in the member declaration, InterfaceI do not lack access modifier , then why I get this error.
Interface
What do you quote in the JLS section in Defining Availability with Names
, ,
, , - ,
ConstantDeclaration: {ConstantModifier} UnannType VariableDeclaratorList ; ConstantModifier: Annotation public static final
public, static final. .
public
static
final
, , . , , , , public.
, ", ". . .
9.3, 9.4 9.5 JLS 8 JLS 7:
, ...
, .
.
, , , " " 6.6.1, , public , . ( , - , .)
, . , -, 6.6.1, , . . , 9.3, 9.4 9.5 , 6.6.1 . , . , , , .
Source: https://habr.com/ru/post/1535080/More articles:Why is this Java application running slowly on a Mac and not on a PC? - javaМедленная билинейная интерполяция Java2D в Java 7 на Mac OS X - javaMissing permission to view page in Django CMS - pythonAndroid Retrofit возвращает статус 500 внутренних ошибок сервера - androidBASH Adding a server name to Apache.conf via AWK - bashCan't publish the version before npm? - node.jsConvert from LinkedHashMap to Json String - javaChanging the attribute type of the master data from Integer32 to String - iosСобытия EditorTemplate не срабатывают - wpfSetting up a python virtual environment using Salt virtualenv.managed or pip.installed? - pythonAll Articles