If a variable is declared as public static varName;
, then I can access it from anywhere as ClassName.varName
. I am also aware that static members a
Well, private static
variables can be used to share data across instances of that class. While you are correct that we cannot access the private static
variables using constructs like ClassName.member
or ClassInstance.member
but the member will always be visible from methods of that class or instances of that class. So in effect instances of that class will always be able to refer to member.