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
-1
votes
2 answers

How to declare a function once in WordPress

I have a WordPress website with Ad Inserter plugin. This plugin has different blocks where I can insert a php code to show it in different position of the post (e.g. after title, after paragraph 1, after content...) I have a php script and I want to…
-1
votes
3 answers

Why do I need to declare a variable in main if it is a return value in Java?

(Sorry if this is so beginner. I'm in an intro class.) Why is Java telling me to declare and initialize 'piglatin' as a variable in the main method when it's a return value? I thought that once it gets initialized in pigLatinWord, it doesn't need to…
-1
votes
1 answer

How do I use relationships btwn 3 integers to determine a triangle and/or what declaration can I use to make this program work?

I am trying to create a program that can use relationships to determine the type of triangle being calculated. I have tried float and double declarations but either way the end result is incorrect and is draving me crazy. Basically the program does…
GamerJ
  • 3
  • 1
-1
votes
1 answer

How can you use a method from a parent controller to set a private variable in php?

I have a simple MVC framework I'm using where I use the following call to load a model in each function in the controller: $member_model = $this->loadModel('Members'); What I would like to do is call that once so every function in the Member…
nikmav
  • 375
  • 1
  • 3
  • 12
-1
votes
3 answers

Type Inference: Java 7 Type Parameters

today we talked about advantages of Java 7 in our company. Since Java 7 there is the possibility to define following line Map> myMap = new HashMap>(); as Map> myMap = new…
agassner
  • 689
  • 8
  • 25
-1
votes
2 answers

Uninitialized local variable used even when declared

So the problem is that I am trying to use the variable speed in a for loop. The error I'm given is: Uninitialized local variable 'speed' used. The strange thing is that I already declared speed as an int before. I'm including the header file, and…
koodeta
  • 83
  • 2
  • 3
  • 14
-1
votes
3 answers

Are variables declared in loops visible to rest of the code?

I was reading this book and it said : Variables declared in a scope aren't visible outside it. It also said : Scopes are declared by 2 curly braces - like a block of code. So, if I had a situation like this : for(_statement1_) { int var; …
ABanerjee
  • 97
  • 1
  • 1
  • 8
-1
votes
1 answer

What are these custom declarations in this C program?

I have a very simple question, what are these declarations in the beginning of this C program called? Normally in a C program you list the , and optionally the . But in the first few lines of this…
yellowhat5
  • 129
  • 1
  • 1
  • 6
-1
votes
4 answers

When to declare something in category .m file or in header .h file?

As we know, normally we used to declare our class instance variables, properties, method declarations in class header file (.h). But we can do the same things, in .m file, using blank category. So my question is: what should be declared in .h file…
Mrunal
  • 13,982
  • 6
  • 52
  • 96
-2
votes
1 answer

Must declare the scalar variable when updating my database

my code: SqlConnection con = new SqlConnection(@"DATA;"); SqlDataAdapter cmd = new SqlDataAdapter(); cmd.InsertCommand = new SqlCommand(" UPDATE TIME set TimeOut = @TimeOut Where TimeOut = @textBox1.Text", con); …
Dennys
  • 3
  • 2
-2
votes
1 answer

"Variable blue might not have been initialized", does that mean I need to declare blue and where?

I'm not 100% sure what is wrong, it just tells me that blue has not been initialized. Millionaire m1 = new Millionaire(response); //Q1 System.out.println("What color is blue?"); System.out.println("1. blue"); System.out.println("2. red"); …
-2
votes
2 answers

Function and varible declar inside a block scope

Can someone explain the output of this code? I see one code test today and do not understand the output. I know it tests ES6 block scope. I'm fine with the first one, but not the others. { function test() {} test =…
Moon
  • 128
  • 3
  • 14
-2
votes
1 answer

How do you define arrays of different sizes using if statements in Java?

So, I was trying to code some test cases for a Java project I'm doing, and I decided that I wanted to move them into a function of their own, and choose between them using a parameter of the test function, rather than just using commenting and…
nick012000
  • 159
  • 2
  • 12
-2
votes
2 answers

What is the best way to declare many variables at once for a single function?

I wanted to use a function to search through a list of possible message values. E.g, a message may be '01 02 03' hex, and then I will check against possible messages if it is any of those. What I don't know is where it is best to declare variables…
Lukali
  • 343
  • 1
  • 4
  • 15
-2
votes
1 answer

javascript variables and google maps distance service

I use Google Maps Distance Service API to get driving distance and time between two points. Here's my code: