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.

Why should the static field be accessed in a static way?

public enum MyUnits { MILLSECONDS(1, "milliseconds"), SECONDS(2, "seconds"),MINUTES(3,"minutes"), HOURS(4, "hours"); private MyUnits(int quantity, String units) { this.quantity = quantity; …

java static
How do I mock a static method that returns void with PowerMock?

I have a few static util methods in my project, some of them just pass or throw an exception. There …

static mocking mockito void powermock
Why can't I declare static methods in an interface?

The topic says the most of it - what is the reason for the fact that static methods can't be …

java interface methods static
When to use static keyword before global variables?

Can someone explain when you're supposed to use the static keyword before global variables or constants defined in header files? …

c static keyword
Static class initializer in PHP

I have an helper class with some static functions. All the functions in the class require a ‘heavy’ initialization function …

php class static constructor initializer
static and extern global variables in C and C++

I made 2 projects, the first one in C and the second one in C++, both work with same behavior. C …

c++ c static global-variables extern
What is the difference between static func and class func in Swift?

I can see these definitions in the Swift library: extension Bool : BooleanLiteralConvertible { static func convertFromBooleanLiteral(value: Bool) -> Bool } …

class static swift
Defining static const integer members in class definition

My understanding is that C++ allows static const members to be defined inside a class so long as it's an …

c++ static declaration definition
Variable declarations in header files - static or not?

When refactoring away some #defines I came across declarations similar to the following in a C++ header file: static const …

c++ c static
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. …

java class static methods synchronized