Use this tag for questions related to declare, which is usually meant for declaring variables, statements, etc.
Questions tagged [declare]
642 questions
214
votes
6 answers
How to declare an ArrayList with values?
ArrayList or List declaration in Java has questioned and answered how to declare an empty ArrayList but how do I declare an ArrayList with values?
I've tried the following but it returns a syntax error:
import java.io.IOException;
import…
![](../../users/profiles/610569.webp)
alvas
- 94,813
- 90
- 365
- 641
125
votes
10 answers
How do I use variables in Oracle SQL Developer?
Below is an example of using variables in SQL Server 2000.
DECLARE @EmpIDVar INT
SET @EmpIDVar = 1234
SELECT *
FROM Employees
WHERE EmployeeID = @EmpIDVar
I want to do the exact same thing in Oracle using SQL Developer without additional…
![](../../users/profiles/706575.webp)
Nathan
- 1,251
- 2
- 9
- 3
95
votes
11 answers
SELECT INTO Variable in MySQL DECLARE causes syntax error?
I´d like to SELECT a single value into a variable. I´d tried to following:
DECLARE myvar INT(4);
-- immediately returns some syntax error.
SELECT myvalue
FROM mytable
WHERE anothervalue = 1;
-- returns a single integer
SELECT myvalue
INTO…
![](../../users/profiles/366256.webp)
Matt Bannert
- 25,237
- 34
- 134
- 195
90
votes
15 answers
Declaring array of objects
I have a variable which is an array and I want every element of the array to act as an object by default. To achieve this, I can do something like this in my code.
var sample = new Array();
sample[0] = new Object();
sample[1] = new Object();
This…
![](../../users/profiles/1957932.webp)
Prasath K
- 4,702
- 5
- 21
- 35
54
votes
2 answers
What does "#!/bin/env" mean (at the top of a node.js script)?
I found serval node.js projects that have this at top of their app.js (as in this openshift program):
#!/bin/env node
What does this mean? How does this work? Where is it useful?
![](../../users/profiles/508236.webp)
hh54188
- 13,085
- 30
- 99
- 174
49
votes
3 answers
Differences between declare, typeset and local variable in Bash
When typing variables in Bash, what is the difference between declare and typeset? When used inside a function: what is the difference between declare and typeset and local?
The only difference I have come across is that typeset is portable to ksh…
![](../../users/profiles/241866.webp)
lecodesportif
- 9,527
- 8
- 31
- 53
47
votes
4 answers
C function pointer syntax
My question is a very simple one.
Normally, when declaring some variable, you put its type before it, like:
int a;
a function pointer may have type like: int(*)(int,int), in case we point to a function that takes two integers and returns an…
![](../../users/profiles/1941583.webp)
user1941583
- 581
- 1
- 4
- 8
43
votes
5 answers
Declare multiple variables in JavaScript
I want to declare multiple variables in a function:
function foo() {
var src_arr = new Array();
var caption_arr = new Array();
var fav_arr = new Array();
var hidden_arr = new Array();
}
Is this the correct way to do…
![](../../users/profiles/238898.webp)
FFish
- 10,538
- 30
- 89
- 133
35
votes
3 answers
typescript declare third party modules
How could I declare a third party module which looks like this:
in third party module:
module.exports = function foo(){
// do somthing
}
in my code:
import * as foo from 'foo-module'; // Can not find a declaration module for ...
foo();
![](../../users/profiles/2694123.webp)
Saman Mohamadi
- 3,402
- 3
- 31
- 52
31
votes
10 answers
Why use constants in programming?
I've just been going back over a bit of C studying using Ivor Horton's Beginning C book. I got to the bit about declaring constants which seems to get mixed up with variables in the same sentence.
Just to clarify, what is the difference in…
![](../../users/profiles/355892.webp)
Adam N
- 319
- 1
- 3
- 3
30
votes
4 answers
MySQL local variables
I am trying to define and initialize a MySQL variable for a query.
I have the following:
declare @countTotal int;
SET @countTotal = select COUNT(*)
from nGrams;
I am using MySQL in Netbeans and it tells me I have an error. What/where is my…
![](../../users/profiles/1104823.webp)
CodeKingPlusPlus
- 12,865
- 46
- 123
- 204
29
votes
3 answers
Why don't methods of structs have to be declared in C++?
Take, for example, the following code:
#include
#include
int main()
{
print("Hello!");
}
void print(std::string s) {
std::cout << s << std::endl;
}
When trying to build this, I get the following:
program.cpp: In…
user3835277
29
votes
2 answers
PHP using Declare ? What is a tick?
I am a little bit confused by the PHP function declare.
What exactly is a single tick? I thought a tick equals one line of code?
But if I use:
function myfunc() {
print "Tick";
}
register_tick_function("myfunc");
declare(ticks=1) {
…
![](../../users/profiles/118027.webp)
opHASnoNAME
- 18,735
- 24
- 93
- 138
29
votes
2 answers
Can I declare the same variable twice in different for loops in JavaScript?
Possible Duplicate:
JavaScript Variable Scope
I have a JavaScript function for HTML select options for days:
// Show and hide days according to the selected year and month.
function show_and_hide_days(fp_form) {
var select_year=…
![](../../users/profiles/1412564.webp)
Uri
- 1,974
- 7
- 33
- 63
23
votes
4 answers
Avoiding declaring private functions in class header files (C++)
(In C++) I have a class whose structure is declared in a header file. That header file is included in lots of source files, such that when I edit it I need to recompile lots of files.
The class has a set of private functions which are only called in…
![](../../users/profiles/664303.webp)
user664303
- 1,995
- 3
- 12
- 30