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.

When to use static classes in C#

Here's what MSDN has to say under When to Use Static Classes: static class CompanyInfo { public static string GetCompanyName() { return "…

c# class static
How do you create a static class in C++?

How do you create a static class in C++? I should be able to do something like: cout << "…

c++ oop class syntax static
calling non-static method in static method in Java

I'm getting an error when I try to call a non-static method in a static class. Cannot make a static …

java static non-static
Static constant string (class member)

I'd like to have a private static constant for a class (in this case a shape-factory). I'd like to have …

c++ string class static constants
"Non-static method cannot be referenced from a static context" error

I have a class named Media which has a method named setLoanItem: public void setLoanItem(String loan) { this.onloan = loan; } …

java compiler-errors static
private final static attribute vs private final attribute

In Java, what's the difference between: private final static int NUMBER = 10; and private final int NUMBER = 10; Both are private and …

java static attributes private final
What is the use of static variable in C#? When to use it? Why can't I declare the static variable inside method?

I have searched about static variables in C#, but I am still not getting what its use is. Also, if …

c# static static-variables
What is the use of a private static variable in Java?

If a variable is declared as public static varName;, then I can access it from anywhere as ClassName.varName. I …

java variables static private
Java: Static vs inner class

What is the difference between static and non-static nested class?

java static inner-classes
Why doesn't Java allow overriding of static methods?

Why is it not possible to override static methods? If possible, please use an example.

java static overriding static-methods