Questions tagged [static-class]

In object oriented programming a static class is a class whose members must be accessed without an instance of the class. Its members must be created as static.

In object oriented programming a static class is a class whose members must be accessed without an instance of the class. Its members must be created as static.

90 questions
0
votes
1 answer

How to initialize and make use of a static class?

I have a static class which is used to access a static concurrentdictionary: public static class LinkProvider { private static ConcurrentDictionary deviceLinks; static LinkProvider() { int numProcs =…
Zapnologica
  • 22,170
  • 44
  • 158
  • 253
0
votes
1 answer

Is a static class kept or disposed after using StaticClass.staticValue

Is a static class kept along with it’s static variables in the memory after using it once, or is it instantiated along with every variable every time I use it? To make it more real lets create an example. Let’s say I want to make a language…
Ganu
  • 39
  • 3
0
votes
2 answers

Is the following "private static inner class" implementation correct?

I have made a public "Utils" class, where I put some general static methods that are frequently used. Inside that Utils class, I have created a private static inner class, of some "tool" that Utils supplies. (That tools is some kind of a parser for…
Hummus
  • 559
  • 1
  • 9
  • 21
0
votes
0 answers

C++ class within a class for BSP recursion algorithm

So I have a class that uses recursion to generate a level. Simple example of BSP dungeon generation. I'm using the code in here. But, I'm writing in C++ so I can't have a static class. The problem is I have this, with pointer of the class in…
simplicity
  • 117
  • 1
  • 6
0
votes
4 answers

Is there any way to use a non-static method in a static class?

I'm trying to implement a simple spreadsheet using Java. It interacts with the user through some menus on the console, and a user can import a given file with some pre-made info about the spreadsheet to be created (lines, columns, and content of…
Rita Pereira
  • 61
  • 2
  • 10
0
votes
2 answers

stackoverflow error in static inner class in Java?

Here is the code where I am updating the instance variable x of OuterClass by static variable of StaticInner. I understand that the static inner classes cannot refer directly to instance variable of outer classes. I am using an instance of…
eagertoLearn
  • 9,772
  • 23
  • 80
  • 122
0
votes
1 answer

iOS: have a clean code, use static class or singleton

I'm developing a game and inside I have a class called StageViewController. I noticed that code inside is becoming very very long and dull. In this class I have controller about gesture, position, animation and it's not easy use static class or…
cyclingIsBetter
  • 17,447
  • 50
  • 156
  • 241
0
votes
1 answer

Create static class instance in android

I saw a code here. Also shown below: I'm in bit confused in Fragment fragment = new DemoObjectFragment(); where public static class DemoObjectFragment extends Fragment is a static class. So how we can call fragment.setArguments(args); public class…
Chris J
  • 949
  • 9
  • 15
0
votes
1 answer

Two instances of application and dll it loads

I have an executable(VC++) which is run twice with different command line parameters, so basically there are two instances running. This executable loads an C# dll ,First thing i want to know is if two instances of the dll will be loaded to two…
user1447725
  • 1,363
  • 2
  • 10
  • 12
0
votes
1 answer

Static/singleton interface implementing class in C#

i have a class that (right now) is static: public static class Grob { public static void Frob() { Foo.Bar(); } } And that works well. Code calls: Grob.Frob(); and all is right with the world. Now i want my class to implement an…
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
0
votes
1 answer

validity of AppContext.getResources().openRawResource()

I have Activity A, Activity B, and a static class in the same application. The scenario is as follows (it's simplified here; it makes more sense in my software): (in Activity A) mAppctx = this.getApplicationContext(); (in Activity A)…
Thomas Calc
  • 2,994
  • 3
  • 30
  • 56
-1
votes
1 answer

Binding to static class/field

I have something of an odd error I am trying to rid myself of. I created a custom .cur Cursor for one of my applications. I have loaded the custom cursor into the project in an image folder, set it to my resources, and made a static class for to…
ARidder101
  • 315
  • 2
  • 6
  • 16
-1
votes
1 answer

Only one copy of static member exists regardless of any no of instance of a class.what does it mean?

I was learning about the static class and static method.Then i came across the following line: Only one copy of static member exists regardless of any no of instance of a class. what does it actually mean? It is in the msdn document…
user35
  • 468
  • 1
  • 9
  • 24
-1
votes
3 answers

A static property in static class when used concurrently

I have a static class 'Logger' with a public property called 'LogLevels' as in code below. When the property is used concurrently in a multi-user or multi-threaded environment, could it cause problems? Do I need to use thread synchronization for…
Sunil
  • 20,653
  • 28
  • 112
  • 197
-2
votes
1 answer

Static or new instance for every object?

I saw some piece of code looks like public class A { public void doSomething(B b) { b.addSometing("queue1", getDefault()); b.addSometing("queue2", getDefault()); b.addSometing("queue3", getDefault()); } private C getDefault() { C…
Daulet Cheri
  • 57
  • 1
  • 1
  • 5
1 2 3 4 5
6