Questions tagged as 'static'

3
answers

What is a static function for?

What is a function with keyword static ? I know that declaring a local variable as static within a function will work as if it were a global variable, and a static function how does it work? And when should you use a sta...
asked by 01.12.2017 / 18:18
1
answer

When does it make sense to only have static methods and attributes in a class?

Studying static methods and attributes in OOP, I came across the following question: why in some codes do we have classes ONLY with static attributes and methods? Is there a design pattern that talks about this? In which cases is this a good...
asked by 22.05.2016 / 22:35
2
answers

How to add static methods in interface?

I have my following method: public static CloudStorageAccount GetAccount() And in my Interface : public interface IAzureStorangeService { CloudStorageAccount GetAccount() } But the compiler accuses that the method was...
asked by 18.11.2014 / 16:31
2
answers

Static Blocks, Inheritance, and Constructors in Java

Hello, during my studies in Java I came across the following doubt Given the code below: class Foo extends Goo { static { System.out.println("1"); } { System.out.println("2"); } public Foo() {...
asked by 17.12.2015 / 17:39
2
answers

Variable static and #define

What is the difference between defining a static variable and using #define in C? Apparently the two have the same function, right?     
asked by 10.11.2016 / 21:47
3
answers

Is the connection to the bank open in static mode?

I have the following static class available for the entire application: public static class MinhaClasse { public static void Salvar(Item meuItem) { using (MeuEntities db = new MeuEntities()) { db.Item.Add(meuItem...
asked by 23.09.2015 / 22:44
2
answers

Static enum constants

enum Animals { DOG("woof"), CAT("meow"), FISH("burble"); String sound; Animals(String s) { sound = s; } } class TestEnum { static Animals a; public static void main(String[] args) { System.out.printl...
asked by 15.12.2015 / 01:11
1
answer

Do instances of the same application share static objects?

I'm developing a Windows Form application in C #, and this application can run simultaneously on the same computer multiple times. And I'm not sure if I should use static objects (classes, functions, variables, etc.) because they might be giv...
asked by 17.10.2018 / 21:22
2
answers

In R, How to calculate the average of one column based on criterion in another column?

I have two columns (A and B) I want to calculate the average of column A for the corresponding elements only for those in column B are greater than 10 for example.     
asked by 11.02.2018 / 19:34
2
answers

When can I use static in the class?

I know that the use of static methods should be avoided, so I have a question and I do not know if it is right to implement ArrayList as static , it is accessed by several classes and contains data from every program (just wa...
asked by 27.09.2017 / 23:31