Most voted "static" questions
51 questions
Sort by count of
-
13
votes1
answer924
viewsWhen does it make sense to have only static methods and attributes in a class?
Studying about static methods and attributes in OOP, I came across the following question: because in some codes we have ONLY classes with static attributes and methods? Is there a design pattern…
-
13
votes4
answers4494
views -
9
votes2
answers450
viewsStatic blocks, heritage and constructors in Java
Hello, during my studies in Java I came across the following question Given the code below: class Foo extends Goo { static { System.out.println("1"); } { System.out.println("2"); } public Foo() {…
-
8
votes2
answers925
views -
7
votes1
answer102
viewsWhat is the difference between a global variable and a global variable Static?
What is the difference between a global variable and a static global variable? Example: #include <stdio.h> int numero = 5; static int static_numero = 5; int main(void) { printf("numero: %d…
-
5
votes2
answers5592
viewsVariable Static and #define
What is the difference between defining a variable static and use the #define in C? Apparently the two have the same function, right?
-
3
votes3
answers339
viewsConnection to the bank is open in static method?
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()) {…
-
3
votes2
answers223
viewsStatic 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) {…
-
3
votes2
answers1129
viewsWhen can I use Static in class?
I know the use of methods static should be avoided, so I have a question and I do not know if it is right to implement a ArrayList as static, it is accessed by several classes and contains data from…
-
3
votes1
answer49
viewsDo instances of the same application share static objects?
I am developing a Windows Form application in C#, and this application can run simultaneously several times on the same computer. And I am doubtful whether or not I should use static objects…
-
2
votes1
answer49
viewsStatic does not share values between web users
It is possible to use a property static without sharing values between different users? Sort of like Session? Ex: of the scenario: private static double valorRetorno; public CalculaValor() {…
-
2
votes1
answer150
views -
2
votes2
answers92
views -
2
votes1
answer40
viewsPage cache is not expiring
I am using the caches_page in a controller in my application in Rails 4. caches_page :index, expires_in: 10.minutes I need to have this controller run again after 10 minutes and generate a new page.…
-
2
votes0
answers46
viewsHow to measure the association between ordinal and nominal variables?
I want to measure the association between gender and the number of assignments of each score in a questionnaire. However, I have a 2x6 reference table with numbers below 5 in more than one box (more…
-
2
votes1
answer421
viewsDefining an abstract attribute in a non-extabstracted class
I want to be able to instantiate an employee class (so this can’t be abstract) and have an abstract salary attribute that will be static for each type of employee. I can do (in the working class):…
-
2
votes1
answer478
viewsStatic properties and memory release
I’m having some doubts regarding the release of resources for cases where my modifiers are static. My project is unit test and I’m using Selenium for the first time. public class LoginTest : Base {…
-
2
votes2
answers1901
viewsIn R, How to calculate the average of a 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 that in column B are greater than 10 for example.
-
2
votes1
answer1157
viewsDjango does not render static files that are in subfolders within /Static/
I am working on a Django project that has static files (css/js/imgs) according to the following structure: File Structure django_project | +apps | +django_project | +media | +static | +admin…
-
2
votes2
answers261
viewsWarning:(40, 5) Do not place Android context classes in Static Fields; this is a memory Leak (and also breaks Instant Run)
I’m coming across this warning from Android Studio. Warning:(40, 5) Do not place Android context classes in Static Fields; this is a memory Leak (and also breaks Instant Run) I have a button that…
-
2
votes2
answers760
viewsInstantiate class with Static method
namespace Classes { class Program { static void Main(string[] args) { Editora ed = new Editora(); Program p = new Program(); ed = p.EntradaDeDados(); ed.InserirProvedorSql(ed); } public Editora…
-
2
votes0
answers131
viewsPHP Methods Static
PHP allows me to have methods static. Whose advantage is to have them accessible without the need to instantiate the class Documentation. However, in the case of methods static, I can use them both…
-
2
votes1
answer81
viewsWhy declare Static for all methods of a Static class?
I was studying here C# until I got to the part about the static. The teacher shows that it is possible to use this statement in methods and even in the class itself. The problem is that when using…
-
1
votes1
answer61
viewsHow do I concatenate a variable into a class with Static function?
Guys I’m having a problem, I have function that when passing card number returns the flag name (visa, Maxcard etc) And I need to return the flag name within a Statica function $bandeira =…
-
1
votes0
answers49
viewsLoad database table by system session
I am developing an application, where one of the modules is the registration of products, and within this register, I have the tax part. In this fiscal part, I have to define an NCM, and according…
-
1
votes1
answer58
viewsStatic objects in Activities with View Pagers
I have an Activity with a view pager, and this one controls three fragments, F1, F2, F3. The F1 fragment shows user-added items, the F2 fragment loads all items from an external server, showing them…
android android-fragment static android-context android-recyclerviewasked 8 years, 2 months ago Guilherme Ramos 343 -
1
votes1
answer120
viewsCalling a static method by name as string in Javascript
If I want to call a static function by name as string, how do I? I did what is below, suppose the function name is "move". class Transformation { static operate(object, function_name) {…
-
1
votes1
answer63
viewsWhat’s the difference if I leave a variable in Otocol marked with Static or without Static in Swift 4?
I’m learning about protocols now, and I saw a code snippet in Swift 4 that defines a protocol, follows below the code snippet. protocol AnotherProtocol { static var someTypeProperty: Int { get set }…
-
1
votes1
answer488
viewsJava Static variable assignment and update
I have a problem with a static variable. In the code I assign a variable that is not Static, the contents of a static variable. Then I update the static variable, only the variable that received the…
-
1
votes0
answers388
viewsDjango MEDIA_URL is not working
Until yesterday it was running smoothly the route /media/ in DEV, and I went to make a production deploy and a production dump for my environment to match, and started giving this problem. I also…
-
1
votes1
answer118
viewsCalling non-static function inside a Handler
I’m developing a code in android studio in which I receive data through a buetooth transmission. The data goes to a function called Handler, which is Static. public static Handler handler = new…
-
1
votes2
answers61
viewsWhat is the static method of that returns an object instance in Java
I believe this method serves to "circumvent" the nay possibility of a method builder static. But what is the function of this? public static MinhaClasse of(OutraClasse outraClasse, Departamento…
-
1
votes1
answer350
viewsHow do I call a function in Swift Xcode
Good evening, I have a function that is attached to a button, I would like to call it directly without the need of the button, what I do? The function... static func goToTutorialOrTo(market: Market,…
-
1
votes0
answers21
viewsExternal static methods not being recognized in the project
I am importing a library of utils into my main project, the library currently contains a single static method, I can import both manually and by Maven, but I am not able to access the static method…
-
1
votes0
answers60
viewsCreate variable javascript constructors
Lately I’m creating javascript classes defining what I don’t want to be public during the constructor, using Noughtclass.myVariable ex: class NovaClasse { static podeMexer = false constructor(){…
-
1
votes1
answer30
viewsStatic no Django
People, Wanted advice or help on the 'Static' in 'Django', my files that are in the 'Static" folder they are not loaded presenting the following errors below: System check identified no issues (0…
-
0
votes2
answers124
viewsStatic Datatable, how to load?
I need to create a method, that when the user logs into the system, when the initial menu is loaded, it loads a Static DataTable, so that I can use the DataTable, for some popular ComboBox, without…
-
0
votes1
answer95
viewsChanging the place templates (Django)
I was trying to leave the templates folder (main) out of the 'core' folder because I actually wanted to leave the 'templates' and 'Static' folder out of the 'core' folder'. Check out my project on…
-
0
votes1
answer86
viewsParameters in Static attribute
I have the following attributes in my class: static String URL="jdbc:jtds:sqlserver://blablabla; databaseName=Pxx"; static String usuario; static String password ; static String…
-
0
votes2
answers94
viewsAccessible class across C#
I would like a class that is not static to be available for the entire application. At first I thought about turning this class into static, but for obscure reasons that are beside the point, I…
-
0
votes0
answers21
viewsHow do you take the value of a static attribute inside a method when you have a variable with the same name in that method?
When it is a non-static attribute you can use the this.nomeAtributo. Example: public class NomeDaClasse { private String atributo; public void (String atributo) { fazerAlgo(this.atributo);…
-
0
votes1
answer1135
viewsWhat is Static in Java? And How to use it?
How can I use the Static in Java? and what is it for? What is its function?
-
0
votes1
answer1187
viewsProblems loading Static files to Django in deploy on Heroku
I’m trying to deploy an app I started in Jango on Heroku, but I’m having trouble loading the css/js/imgs files, follow below as my folders and settings related to it! py Settings. BASE_DIR =…
-
0
votes2
answers45
viewsArraylist statico returns size 0 when I try to recover it in an Activity
I have This class: abstract public class ListaEstaticaDeErros { private static ArrayList<DescritorDeErro> listErros = new ArrayList<DescritorDeErro>(); private static boolean fimSinc =…
-
0
votes2
answers217
viewsUse of chained static functions
I wanted to use static PHP functions as follows: class A { static function a1() { echo "A1"; return A; } static function a2() { echo "A2"; return A; } } A::a1()::a2(); Works, but shows this error:…
-
0
votes0
answers86
viewsWhat is the difference between self and __CLASS__?
Studying the Singleton design pattern, I was running some tests: class Test { public static $var = "XYZ"; static function class() { return __CLASS__; } static function self() { return self::$var; }…
-
0
votes0
answers31
viewsAndroid Studio How to reference Activity within a Static method
I needed to create a static method in the main Activity, because Firebase is not accepting Framents within the CreateUserWithEmailAndPassword. I would like to know how I refer to the main Activity…
-
0
votes2
answers736
viewsError: non-static variable this cannot be referenced from a Static context
This code is giving error: non-static variable this cannot be referenced from a Static context When I take the static main does not look like the warnings in Netbeans, but when compiling it makes an…
-
0
votes1
answer36
viewsProblems using "using" to access static methods
I created in C# a static class with the methods Decode() and Encode() as in the code below: namespace Crypt { public static class CaesarCipher { public static string Decode(string text, byte key) {…
-
0
votes1
answer20
viewserror: non-static variable this cannot be referenced from a Static context / Java 8
I am doing a URI (online Judge) exercise but is showing "Compilation error" due to error: Main.java:8: error: non-static variable this cannot be referenced from a Static context Interfacetext i =…