Questions tagged [variable-declaration]

In computer programming, variable declaration specifies properties of a variable (such as its type).

In computer programming, variable declaration specifies properties of a variable:

  • It associates a type and an identifier (or name) with the variable.
  • It allows the compiler to decide how much storage space to allocate for storage of the value associated with the identifier and to assign an address for each variable which can be used in code generation.
663 questions
-2
votes
1 answer

Variable declarations with get/set

Why do people do this int myInt { get; set; } rather than just this? int myInt;
cj32
  • 23
  • 6
-2
votes
1 answer

What is purpose of type on the constructor side of Java collection creation?

What is purpose of re-specifying the type on the right / constructor side of a Java Collection declaration + instantiation? For example, how is List a = new ArrayList(); different / better / worse than List a = new…
yokeho
  • 177
  • 1
  • 7
-2
votes
2 answers

Which one gives me better performance in variables declaration?

I need to know which one of the following examples gives me higher performance? Object O = someValue; if (condition){ //statements //statements } else { //statements //statements } Or Object O; if (condition){ O = someValue; …
-2
votes
1 answer

Java string declaration IntelliJ IDEA

Trying to declare a string in Java inside the main method of a Console application. String s = "this is some text"; I get a red underline saying, 'class' or 'interface' expected. If I change the code to read String s = new String("this is some…
doop_dev
  • 29
  • 7
-2
votes
1 answer

Describe: int (*(*var[3])())(void (*)());

int (*(*var[3])())(void (*)()); How would you describe the type of var in the above declaration? I get: Declares var as array of 3 pointers to functions (A) These functions (A) take any inputs and return a pointer to a function (B) These functions…
Jamila
  • 3
  • 1
-2
votes
1 answer

Why is no name collision occuring with struct declaration

I created a struct: struct number_struct { int i; float f; } struct_a; Thus struct_a is of type number_struct. Later in int main I write: number_struct struct_a = { 0 }; number_struct struct_b = { 0 }; The confusion is that since I have…
quantum231
  • 2,420
  • 3
  • 31
  • 53
-2
votes
1 answer

What does it mean to enclose a function in parentheses before passing it into a variable?

I saw this on some sample code var foo = (function(){ //some code })(); What does this mean? and how is it different from var foo = function() { //some code } I saw that here where the original code was: var registrationForm = (function()…
davidx1
  • 3,525
  • 9
  • 38
  • 65
-2
votes
2 answers

Map type Declaration difference

What's the difference between Map exemple = new HashMap<>(); And Map exemple = new HashMap();
OddDev
  • 1,521
  • 7
  • 23
  • 45
-2
votes
1 answer

moving variable declarations outside for loop

File: bodies.cpp for (int i=0; i
Alvaro Gomez
  • 350
  • 2
  • 7
  • 22
-2
votes
1 answer

Declaring variable and assignment

I was just practicing java program in eclispe following is the code: import java.util.*; class Problem7 { public static void main(String args[]){ int num,sum=0,mod_num,count;//Syntax error on token ";", { expected after …
Ricky
  • 133
  • 4
  • 16
-2
votes
1 answer

Declaring instance without variable name c++

After asking C++ Error linking in consumer file caused by static data field, I tried two different declarations for an instance of StateConservator: StateConservator cs(*pContainer, pDoc->GetConfiguration()); and StateConservator(*pContainer,…
sergiol
  • 4,122
  • 4
  • 47
  • 81
-2
votes
2 answers

Is this sentenced to call constructor?

public class TestBikes { public static void main(String[] args){ Bicycle bike01, bike02, bike03; bike01 = new Bicycle(20, 10, 1); bike02 = new MountainBike(20, 10, 5, "Dual"); bike03 = new RoadBike(40, 20, 8,…
Leonne
  • 85
  • 3
  • 10
-2
votes
2 answers

In Javascript declarations, what does "?" along with ":" mean?

In a Javascript program to convert a Julian day to a calendar day, the following code is seen: month = (G<13.5) ? (G-1) : (G-13) year = (month<2.5) ? (C-4715) : (C-4716) I thought these may have been some sort of conditions that changed the…
pkshultz
  • 409
  • 1
  • 3
  • 16
-2
votes
1 answer

javascript array values not available outside function

I'm sorry to ask this but I've looked everywhere, and cant follow this. I'm trying to re-work a v2 google maps example to make it go in v3. I have a set of 'end points' within a driving distance of a central point I want to draw a polygon…
-3
votes
1 answer

Do values need to be initialised to function in for loops?

I'm learning c++ and our Prof. wants us to understand whether the things we have learnt would/wouldn't function in other languages. Would the following code in python print "I love my dog ..." (for every array instance) AND "my favourite dog is…
Wise
  • 69
  • 7