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
3
votes
1 answer

Why we declare the nested public static class in java, even though its being used in some other places as well?

I was going through the legacy code base and observed that so many places they are using the public static class inside an outer class and nested public static class is not just being used in the outer class but its being used in so many other…
user7851946
3
votes
0 answers

How to Unit Test ES6 Static Class with Sinon (spy/stub/mock)? child function, internal function [JS + SINON]

Below there is a simplified version of the static class I want to test using Chai, Sinon and Mocha. It exposes 2 functions and has another internal. //demo.js const parentFunc = (baseNum) => { return childFunc(baseNum, 10); }; const childFunc…
3
votes
2 answers

How recursive inner static class get initialized?

i was looking into Trie data-structure and came across this piece of code // R-way trie node private static class Node { private Object val; private Node[] next = new Node[26]; } i understood the logic, but what i don't get…
abhirathore2006
  • 3,317
  • 1
  • 25
  • 29
3
votes
4 answers

Is there a performance cost to static inner class?

Is there a performance cost to static inner class? Or should I just write the same static class as a non-inner class?
Ray
  • 12,101
  • 27
  • 95
  • 137
3
votes
3 answers

How to clear out or delete an unnamed widget-pool containing my static class

I'm working with Progress 10.1c I have a class that contains both static and non-static methods. The class is defined with USE-WIDGET-POOL. In the destructor I say "DELETE WIDGET-POOL". I create an instance of my class, and call a method. The method…
RobertT
  • 1,213
  • 10
  • 12
2
votes
2 answers

Using static methods to interface with a database - any potential problems?

I'm looking at a class handling database access for an MVC3/.Net application. The class is static, and provides nice convenience methods for common DB queries - all sorts of twiddly stuff like "GetColumnBValueForColumnA()", as well as much more…
blueberryfields
  • 45,910
  • 28
  • 89
  • 168
2
votes
3 answers

Singleton and static classes case study

It was already asked what's the difference between singleton and static class. However, knowing the difference, I still feel confused every time I need to chose. So for myself I defined two different cases - I'm using singletones mainly for POJO…
Sergey
  • 11,548
  • 24
  • 76
  • 113
2
votes
2 answers

ASP C# Interfaces

I am working with ASP.NET MVC5 project. I am new to commercial programming and I am a little bit confused about Interfeaces, I haven't use them before. I have project which is almost done. Here is an example: public interface IUserService() { …
miechooy
  • 3,178
  • 12
  • 34
  • 59
2
votes
3 answers

Java syntax to invoke a constructor of a static nested class

I learnt that static class is a class whose members MUST be accessed without an instance of a class. In the below code from java.util.HashMap, jdk 1.8, public class HashMap extends AbstractMap implements Map, Cloneable,…
overexchange
  • 15,768
  • 30
  • 152
  • 347
2
votes
1 answer

Make button visible with StaticClass and Save it

I still got confused with StaticClass code which given from my friend to alternative save besides Shared Preferences, already 3 days I tried learned the code and asked but there is still a little problem with a code this is the latest following code…
RichFounders
  • 169
  • 21
2
votes
1 answer

Set StaticClass to save my current Button set to Visible with GUI Handler

i got confused with StaticClass code which given from my friend to use GUI handler to alternative save besides Shared Preferences I had this following code in my selectlevel.class public class selectlevel extends Activity { Button f1, f2, f3; …
2
votes
1 answer

Why LinkedList implementation in java has Node nested class as static?

I developed my own small implementation of LinkedList without using Node nested class as static and it is working fine.... But Java Uses Node nested class as static.I didn't find a strong reason to make Node nested class as static. Can anyone help…
Aditya
  • 41
  • 2
  • 4
2
votes
3 answers

Is marking a class as static a binary breaking change?

I have a utility class that only contains static methods. If I mark the class as static, is that a breaking binary change? I've compared the IL for both, and besides the loss of the default constructor (that should never be used), I can see the…
Giles
  • 1,331
  • 1
  • 15
  • 30
2
votes
2 answers

Java - Anonymous class are static or not

I know it depends on the context in which the anonymous class has been written (static or non static method). but look this part of code: public class A { int fieldOfA; private static class B { int fieldOfB; } public static…
Giovanni Far
  • 1,623
  • 6
  • 23
  • 37
2
votes
2 answers

Are public static members (properties) of static class thread safe

I have a sample static class public static class SampleClass { private static readonly string _personName; private static readonly string _country; static SampleClass() { _personName = "JourneyMan"; _country =…
Sandepku
  • 861
  • 14
  • 31