Latest Questions tagged Static

Browse all latest questions tagged Static

Published 27 Oct, 2022
Java - How to access global non static variable from static method

I have main method in my java program, I want to store values in global variable because i want to access that values from different methods of the class, however I am not convinced to use static glob...

Published 14 Sep, 2022
Java - Modifier static is only allowed in constant variable declarations

I have an inner class that stores the info of the controls I'm using for a game, now I want to store a static ArrayList in it that holds all the names of the controls. But I am getting this error: &qu...

Published 04 Jun, 2022
Python - Static Arrays in Python

I am learning how to program in python and am also learning theory as part of a computer science course. In programming i know that i can add additional variables to an array just by using the .append...

Published 24 Apr, 2022
Javascript - TypeScript static classes

I wanted to move to TypeScript from traditional JS because I like the C#-like syntax. My problem is that I can't find out how to declare static classes in TypeScript. In C#, I often use static classe...

Published 14 Sep, 2022
Java - What is the equivalent of Java static methods in Kotlin?

There is no static keyword in Kotlin. What is the best way to represent a static Java method in Kotlin?

Published 16 Sep, 2022
Java - How to undo/reset PowerMockito.mockStatic?

Assuming I have the following classes public class StaticClass { public static void staticMethod() throws SomeException { System.out.println("staticMethod"); } private StaticCla...

Published 07 Sep, 2022
Java - Java synchronized static methods: lock on object or class

The Java documentation says: It is not possible for two invocations of synchronized methods on the same object to interleave. What does this mean for a static method? Since a static method h...

Published 29 Aug, 2022
Java - Why are static variables considered evil?

I am a Java programmer who is new to the corporate world. Recently I've developed an application using Groovy and Java. All through the code I wrote used quite a good number of statics. I was asked by...

Published 30 Aug, 2022
Java - Accessing an instance variable in main() method?

class Test { Test obj; public static void main(String[] args) { obj = new Test(); } } I am aware of the fact that instance variable and non-static methods are not accessibl...

Published 05 May, 2022
Python - What is the absolute path of BASE DIR?

Django newbie here. I have trouble understanding the meaning of: BASE_DIR = os.path.dirname(os.path.dirname(__file__)) and STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static') STATICFIL...

Published 18 Sep, 2022
Java - Java: Static Class?

I have a class full of utility functions. Instantiating an instance of it makes no semantic sense, but I still want to call its methods. What is the best way to deal with this? Static class? Abstract?...

Published 22 Aug, 2022
Java - Java - are constructors static?

I just wrote a constructor like this: public ArchivesManager(String identifier) { String[] components = String.split("\nNEW"); } But there's an error message: non-static method split(java.lang....

Published 11 Sep, 2022
Java - why are java constants declared static?

Why are java constants declared static ? class Foo{ static final int FII = 2 ; } In this I understand the use of final? Buy why does it have to be static? Why should it be a class variable, and...

Published 24 Apr, 2022
Python - Django set image src path

I want to set an image as a submit button form: <form action="/final" method="post">{% csrf_token %} <input type="hidden" name="title" value="niloofar"> <input type="image" nam...

Published 07 Sep, 2022
Java - How do I create a static local variable in Java?

I've read Java does not support static local variables unlike C/C++. Now if I want to code a function with a local variable, whose value should persist between function calls, how do I do that? Should...