0

I am a little bit confused. Suppose I have a method

void test(){ }

How exactly can I make this package-protected? The protected modified makes it overridable by children.

dfdf
  • 147
  • 1
  • 9
  • 2
    Do you mean package private? If so, you already did. If not, you can't. – Dawood ibn Kareem Feb 20 '19 at 23:55
  • 1
    It already is! No `private`, no `public` and no `protected` makes it package-protected (aka default) access. – Elliott Frisch Feb 20 '19 at 23:55
  • Hi, please refer to the following article for more explanation about access modifier. Method or class without access modifier means it has default access modifier. https://www.geeksforgeeks.org/access-modifiers-java/ – Pajri Aprilio Feb 21 '19 at 02:45

1 Answers1

1

If you declare it as

void test(){ } 

It means this function is package-private. Other classes can use it if they are in the same package.

LuminousNutria
  • 1,883
  • 2
  • 18
  • 44