Top "Static" questions

Static is a term used in some programming languages to define a function or data storage area (field) that is not bound to any specific object instance.

Can I add extension methods to an existing static class?

I'm a fan of extension methods in C#, but haven't had any success adding an extension method to a static …

c# static extension-methods
In laymans terms, what does 'static' mean in Java?

I have been told several definitions for it, looked on Wikipedia, but as a beginner to Java I'm still not …

java static reference
Why doesn't Mockito mock static methods?

I read a few threads here about static methods, and I think I understand the problems misuse/excessive use of …

java methods static mockito
Static Block in Java

I was looking over some code the other day and I came across: static { ... } Coming from C++, I had no …

java static
Getting the class name from a static method in Java

How can one get the name of the class from a static method in that class. For example public class …

java static
Static variable inside of a function in C

What will be printed out? 6 6 or 6 7? And why? void foo() { static int x = 5; x++; printf("%d", x); } int main() { foo(); …

c static
What is the lifetime of a static variable in a C++ function?

If a variable is declared as static in a function's scope it is only initialized once and retains its value …

c++ static lifetime
The static keyword and its various uses in C++

The keyword static is one which has several meanings in C++ that I find very confusing and I can never …

c++ static
TypeScript static classes

I wanted to move to TypeScript from traditional JS because I like the C#-like syntax. My problem is that …

javascript class static typescript
C++ where to initialize static const

I have a class class foo { public: foo(); foo( int ); private: static const string s; }; Where is the best place …

c++ static initialization constants