I'm getting super confused with all this public private static stuff

Decided to hop into another project after a long while of no programming, which sadly had to be in Java. Not sure if this only applies to Java, or other languages as well though. After looking at some source code, I began to get super confused about the exact meaning of all this public static and private static stuff.

I guess my understanding of what public and private methods actually are, but as far as I know public methods can be accessed from any class, while private methods can only be accessed by the parent class and its methods.

Then what exactly is static? Googling and having a long explanation with ChatGPT only made me more confused, so could someone explain what static is and how exactly static methods work? When would you use public and private along with it and why do you even need to use it in the first place?

1 Like



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.