Most of the methods that I instantiate in several classes ask me to change it to "packetLocal". Example:
public void example ();
go to
void example ();
So, should the methods be public or not?
Most of the methods that I instantiate in several classes ask me to change it to "packetLocal". Example:
public void example ();
go to
void example ();
So, should the methods be public or not?
In this case surely the access to your method is done only within the package , for this reason the best practice is to use the default access modifier and it is not necessary to add a modifier of access . It should not be public because it would be visible to everyone, it would be accessed from any class or instance that in your case is not necessary.
public
: visible to everyone.
protected
: visible within the package and all subclasses.
private
: visible only to the class that contains it.
default
: in case this level of accessibility is visible within 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 will have access to the method, if you remove the public
it will become private
and you will only have access to the method from your same class.