static modifier in an attribute

0

I'm wondering if the static modifier needs to be in the same package as the other classes in my project.

Example: I have a class named User within the Users packet and another class named Constants within the Metodos package. The problem is that I am not able to call the static VALUECONSTANT variable of the class of the same name in the Users class.

    
asked by anonymous 10.03.2018 / 20:18

1 answer

0
public class Stuff {
    public final static String NAME = "I'm a static variable";
}

And in another package, since import has been correctly performed

public class Application {

    public static void main(String[] args) {
        System.out.println(Stuff.NAME);
    }

}

Example and Source: link

    
10.03.2018 / 21:30