0
I’m wondering if the Static modifier necessarily needs to be in the same package as the other classes in my project.
Example: I have a class called user within the user package and another class called valuesConstants within the Methodosutes package. The problem is that I am unable to call the static variable CONSTANT VALUE of the class of the same name in the class Usuarios.
Is there an error, could you give some more details? Or code how you are trying to access the constant? It may be a line
– Sveen
no, no mistake, actually it’s just a doubt I have. I usually bypass it using get methods to return me the value
– AlexSusama
Static is not about visibility, but whether the variable will exist only when there is an instance or whether it exists independently of it. What defines visibility are the private, public modifiers and when it is without modifier, which is the Packet visibility.
– user28595
Related: What is the difference between public, default, protected and private modifiers?
– user28595
Related: Best practices regarding the use of access modifiers
– user28595
then if she has the public modifier in another package I will still have access to the value it contains?
– AlexSusama
boot a code @Alexsusama, sometimes it’s something simple
– Sveen