0

I have a Class RequestHelper where I store methods for http-Requests to initiate Requests from different Activities.

E.g. there is this one:

class RequestHelper {
    static void loginUser(String email, String password, final Context activityContext) {
    // do request stuff
    }
}

Is there any difference if I put a public in front of it like in the following example or is it just nonsense to do so?

class RequestHelper {
    public static void loginUser(String email, String password, final Context activityContext) {
    // do request stuff
    }
}

Both versions do work as planned, so is there any difference at all?

laka
  • 644
  • 8
  • 23
  • 1
    Maybe this can help: https://stackoverflow.com/questions/215497/what-is-the-difference-between-public-protected-package-private-and-private-in – ernest_k Oct 18 '18 at 15:55
  • The first one with no public should be having a package-private scope while the second is available to all classes – mettleap Oct 18 '18 at 15:57
  • *"Is there any difference if I put a public in front of it"* Yes: It will be available outside the package your class is in. See the linked question's answers for details. :-) – T.J. Crowder Oct 18 '18 at 15:57

0 Answers0