Most voted "static-variable" questions
5 questions
Sort by count of
-
14
votes1
answer615
viewsHow does the lifespan of static variables work?
I just saw a question about C. In it the following code was shown: #include <stdio.h> int main() { static int a = 5; printf("%d", a--); if(a) main(); return 0; } Example running on repl.it.…
-
8
votes1
answer127
viewsStatic members are collected by GC when no longer needed?
In a class that has a static variable, it exists throughout the application. The linked object is collected at some point? Example: public class Exemplo { private static List<int> lista = new…
-
5
votes1
answer106
viewsI don’t understand the order to execute a code
public class Rope { static String result = ""; {result += "c";} static {result += "u";} {result += "r";} public static void main(String[] args) { System.out.print(Rope.result + " ");…
-
3
votes1
answer425
viewsHow does Python handle static and dynamic variables?
Static variable, is the one where we separate the memory of the computer already defined beforehand (I read this in the book "Basic data structure"). The dynamic variable, on the other hand, is one…
-
1
votes1
answer104
viewsHow to use static property of a class in another class in PHP?
I am venturing into the world of POO in PHP and I came up with the following question. Of the four ways I used in the code below, to assign the value of $prop1 of MinhaClasse to the variable $val…