Most voted "variables" questions
A variable is a named data storage location in memory. Using variables , a computer program can store text numbers, binary data, or a combination of any of these data types. They can be transferred in code, to other functions and even other applications.
Learn more…645 questions
Sort by count of
-
9
votes3
answers308
viewsHow to "create" a variable in "Runtime"?
I’m doing a project that implements a Python-style console. It has several functions, it has many things. But I need to implement a command called set. set declare a character string and define its…
-
9
votes5
answers10429
viewsHow to exchange the value of two variables in Java?
You can create a Java function that changes the value of two variables without having to declare a temporary variable? For example: int a = 8, b = 3; if(a > b) { // algo aqui, sem declarar uma…
-
9
votes3
answers8723
viewsDifference between "Attribute" and "Instance Variable"
Reading some books and articles about introduction to Java and OO I realized that these terms are not well defined. Looking deeper I found different definitions in different sources on the subject.…
-
9
votes1
answer289
viewsWhy use a private?
I’m learning variables public and private. If it is I who create all the code of the program, what is the need to create a variable private? It is enough that I do not program a code that accesses…
-
9
votes4
answers2583
viewsCan PHP’s unset() function improve performance?
I think the answer to my question would be "yes." even because I end up doing it in my code (when I remember), but I just stopped to think about it now and I’m kind of worried if someone asked me…
-
9
votes1
answer1539
viewsWhy use VAR in PHP?
Why use VAR in php if we can already declare variables without VAR? We can do this: $teste then why do it? var $teste For example, it’s the same thing I do? class Caneta { var $modelo; var $cor; }…
-
8
votes6
answers7569
viewsUse of global variables and class variables in Delphi
I have some questions regarding the use of global variables and class variables using class var at Delphi. Declaring class variables with class var. unit Unit1; interface type TClass = class public…
-
8
votes3
answers954
viewsHow to list variables defined within a Javascript scope?
How do I know/list which variables have already been defined within a scope, whether global or local? For example if I set var x, y, z = 10, the result of a possible command to list the variables…
-
8
votes3
answers21946
viewsHow to exchange the value between two variables without using auxiliary variable?
I learned to code in C, but recently I have studied RUBY. Ruby allows us to exchange the value between two variables easily and without using an auxiliary variable, thus: a, b = b, a Without using…
-
8
votes2
answers209
viewsProcessing time is affected by the size of variable names?
I was analyzing some frameworks developed by large companies and noticed a certain uniqueness, its variables and functions usually have small names. Variable or function name size interferes with…
-
8
votes1
answer1158
viewsRecommended form for popular variables with database data
Assuming this fictitious method to obtain database data, say SQL Server: public List<DadosDTO> ObterDados() { try { comand = connectionFactory.CreateCommand(); comand.CommandText = "SELECT…
-
8
votes1
answer148
viewsHow/why to chain variables with operator = (equality)?
Sometimes I come across these statements chained in source some libraries and are usually many chained statements. For example: var foo = foo2 = foo3 = 'foovalue'; However I could never understand…
-
8
votes5
answers1617
views -
8
votes4
answers827
viewsAnother option to use @ in PHP?
I don’t feel very comfortable having to use the @ before some variables and sessions when making conditions, to avoid error of Unexpected Index which happens when the variable or session was not…
-
8
votes5
answers26812
viewsWhen is isset required?
I would like to know when it really is essential to use the isset variables in PHP, especially in the case of forms. What happens is that I am creating a large form, with some 200+ fields, which…
-
8
votes2
answers193
viewsHow does a variable point to a pointer?
Reading this answer on pointers and arrays in C, there is the example below where the variable ptr points to the first element of this array. int array[42] = {42}; int *ptr = a; How this pointer…
-
8
votes1
answer583
viewsUse "Fieldbyname" or the associated variable?
When I have a ClientDataset, one MemoryTable or a Query, what’s the difference if I take the value of a field using FieldByName() or the variable associated with the field? In the example below, I…
-
8
votes2
answers1582
viewsVariable of the foreach loop
When we use a loop loop foreach, the local variable we create to receive the contents of the list in question is passed by value or reference? Ex: foreach (var item in listItems) { //TODO } The…
-
8
votes2
answers3945
viewsJavascript usage of ${variable}
I was reading this article on AJAX when I came across this way of using a variable inside a string: let cep = document.getElementById('cep').value;…
-
7
votes2
answers745
viewsSet values or not in c++variables
Good night. Should I or should I not set values in variables when creating them in c++? An example: int x = 0; int y; What’s the difference in these two cases? And what happens in memory when I…
-
7
votes5
answers675
viewsWhy does Netbeans warn you not to access global variables directly?
Netbeans suggests that we do not access the global variables of PHP type $_SERVER[''] directly, what is the suggestion in this case? It’s usually done this way: <?php $ip =…
-
7
votes2
answers1833
viewsError: Object of type 'float' has on Len
I was thrashing simple operations on the Python interpreter, and the following command made me curious: >>> b = 3.12; len(b) With the following error: Traceback (Most recent call last):…
-
7
votes1
answer2081
views -
7
votes1
answer10908
viewsWhat does a double precision variable mean?
I would like to understand the meaning of a variable of double precision.
-
7
votes3
answers403
viewsBest practices in Javascript variable declaration
In the MDN Variables section we have the following statement: For that Reason, it is Recommended to Always declare variables at the top of their Scope (the top of global code and the top of Function…
-
7
votes3
answers815
viewsIn PHP are all variables declared global?
In C# there is the concept of local variables, see the example below: if (true) { int valor = 10; } else { valor = 5; } Console.Write(valor); The above code returns an error saying that the variable…
-
7
votes2
answers2933
viewsWhat is the difference between global and superglobal variables?
I read some time ago that PHP has the vast majority of its variables declared with local scope. But I found two others concepts variables global and super-global and I didn’t quite understand the…
-
7
votes3
answers189
viewsGlobal and local scope variable
If I print the global scope variable within a local scope, I am not allowed to redeclare again in the local scope. Why? For example, if I do: let a = 2; { let a = 3; console.log(a) //aqui aparece 3…
-
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…
-
6
votes1
answer134
viewsWhat is the difference between variables declared as final and private?
What is the difference between these two types of variables and why can’t they be accessed in certain parts of the code? I read about private, public and abstract methods, but did not understand the…
-
6
votes2
answers1271
viewsDoes the memory consumption of a variable increase each time it is used?
I have been trying to understand more about the memory consumption of the created variables. And I even did some tests here on my computer with variables! I then created some variables and used it…
-
6
votes1
answer838
viewsHow to print the variable name in C?
Example: I have an entire variable called menino, how do I print on a printf() the name of that variable, i.e. "menino"
-
6
votes3
answers101
viewsIs there any justification for this change? Change in variable pattern
A coworker read on a forum that using shorts, int and long was the right and best way for the system’s performance, so it began to change on all screens and classes it worked on. I searched and saw…
-
6
votes1
answer558
viewsTry/catch on JS
I own a array called agenciasUri, which format the data before inserting into it. After that, I mount JSON jsonObjto send a request. What I found strange is that it is working properly. Why can I…
-
6
votes2
answers379
viewsIs it bad practice to overwrite declared variables as a function parameter?
I used to get "reassigned" a value of a certain variable that was declared as nome of the function parameter. Example: function format($string) { $string = ltrim(rtrim($string, ']'), '['); // A…
-
6
votes4
answers931
viewsHow to verify variables that are not used?
Is there any way to verify which variables are not used within the scope one-class? As in the example below, the variables teste1 and teste4 has no utility within the application, as could locate…
-
6
votes1
answer4695
viewsHow to identify the type of variable in C?
In languages such as Nodejs, Ruby, Moon, etc. When I want to know what the type of my variable is just use the function typeof (not necessarily in the cited languages) that returns a String with the…
-
6
votes1
answer84
viewsHow to start a variable correctly?
There is a difference between these two ways to start a variable? List<classeterapeutica> itens = new List<classeterapeutica>(); modelOff.classeterapeuticas.ToList(); or…
-
6
votes2
answers1649
viewsWhat is the underscore (or underline _ ) for in the repeating structure?
What this _ ago? Why it is being used in the code snippet below? print('3 numeros') data = [] for _ in range(3): data.append(input()) numbers = list(map(int, data)) print(numbers)…
-
6
votes1
answer111
viewsDifference between overall, const and define()
So I was studying about POO and MVC structures with PHP and saw that we often need to use global variables (accessible throughout the application) and what’s the difference of using: global $nome =…
-
6
votes1
answer79
viewsWhat is the difference between the function "malloc()" and a created variable?
I was reading some codes in C and I realized that to generate some specific object is used the function malloc(). It is not easier to create this object in a variable than to use the malloc()? Here…
-
5
votes3
answers2379
viewsHow to see how much memory occupies such a variable in C++? And how to use the define?
How to see how much memory occupies such a type variable int, char e long in the C++? And how to use the #define?
-
5
votes2
answers887
viewsCheck if variable has been set
How do I check if a variable has been set? The #ifndef can be used for this? Plainer: #include <iostream> int getNumber() { if (check) { check = false; return 10; } else { bool check = true;…
-
5
votes2
answers214
viewsMake a reference variable point to another variable
I have the following question, for example: int a = 5; int b = 10; int & r = a; How do I use the reference variable r point to b and no longer to a? It is possible to do this?…
-
5
votes1
answer59
viewsDoubt cast with pointer
while( ++idx <= fp_size) { byte current = buff[idx]; int integer = 0 ; short shortint = 0 ; if(idx < fp_size - 3) integer = *((int *))&buff[idx]; } What kind of cast is this *((int *))?…
-
5
votes2
answers1476
viewsHow to leave variables privately in Javascript?
How to leave a private variable, because I had trouble using the same variable name that was already implemented in another JS file and that I didn’t remember. How to create this private variable to…
-
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?
-
5
votes3
answers148
viewsVariable is not updated in constructor
I’m learning OO and venturing into PHP, only I came across something that I think in theory should work, but in practice does not work. <?php class Users{ public $name; public $idade; public…
-
5
votes3
answers2397
viewsHow to check if there is a certain number in a php variable?
So I was doing a search, looking for some php function that checks if a certain number exists within a variable. And I found the preg_match(). Only that has a however, php gives an error and so I…
-
5
votes2
answers265
viewsShould I use a variable that takes an HTML element as global or local?
function message (className, text) { /*Esta variável*/var message = document.getElementById("message");/*Esta variável*/ message.className = className; message.innerHTML = text; setTimeout(function…