If I make a static object variable, ALL the variables contained in that object become static?


In other words, if I make this variable of the Dog object, all its class variables (properties, such as race, color, namePerror) are also made static together with the object variable "dog"?

class ejemplo{
    public static Perro perro;

My question is derived, because I have a local variable in a method (Inside the Dog class, which assumes that its lifetime only lasts while the method is executed and it finishes its execution, and it turns out that when it returns to execute that method, the value that had put to that variable is maintained, and this is not supposed to be, since my variable is only local, it is not a class variable, much less it is a static variable.

I've been programming for years and this has never happened to me, what happens? I'm confused.

My only theory is that it is because I declared "dog" as static, or because I am programming with multiple threads and each thread has a value of that variable .. I do not know

asked by Missionary robot Robot 04.12.2018 в 22:58

0 answers