+ 4

Can anyone explain me access modifiers - 'protected' and 'default?

Actually? I am having a little difficulty understanding 'protected' and 'default' access modifiers. Please help me understand it.

20th Jan 2018, 3:12 PM
Sahib Gill
Sahib Gill - avatar
1 Resposta
+ 2
methods and fields which are protected can be used only by classes that extend the given class, that means class Foo{protected int a=0;} a can be used only in class which extends Foo (or extends something what extends Foo etc.) class Another extends Foo{ //here can be variable a used } when you don't put any access modifier the methods and fields are visible within the package of the class
20th Jan 2018, 5:19 PM
michal