Most of the methods I instantiate in various classes ask me to change it to "packetLocal". Example:
public void example();
pass to
void example();
So should the methods be public or not?
Most of the methods I instantiate in various classes ask me to change it to "packetLocal". Example:
public void example();
pass to
void example();
So should the methods be public or not?
In this case the access to your method is probably done only inside the package , for this reason the best practice is to use the default access modifier and it is not necessary to add an access modifier . It should not be public because it would be visible to everyone, it would be accessible from any class or instance that is not necessary in your case.
Access Modifiers :
public
: visible to everyone.protected
: visible inside the package and all subclasses.private
: Visible only to the containing class.default
: In the case of this level of accessibility it is visible inside the package and no modifiers are required.Here is a good article for more information:
Public, protected, default and private access modifiers in Java.
This depends on how you are using the methods if you leave it with
public
other classes they will have access to the method, if you remove the itpublic
will becomeprivate
and you will only have access to the method from your own class.