Top "Local-variables" questions

Local variables have a limited scope, generally one function or one functional block.

Can i declare a static variable inside static member function in Java?

private static int Fibonoci(int n) { static int first=0; static int second=1; static int sum; if(n>0) i am …

java function static local-variables
access variables of outer class in Java

in Java android application how can i access variables of outer class from the inner anonymous class ? Example: ProgressDialog dialog = …

java local-variables anonymous-inner-class
"Life-time" of a string literal in C

Wouldn't the pointer returned by the following function be inaccessible? char *foo(int rc) { switch (rc) { case 1: return("one"); case 2: …

c function local-variables string-literals lifetime
C++ local variable destruction order

Is there a defined order in which local variables are deallocated in C++ (11) ? To be more concise: In which order …

c++ c++11 destructor local-variables
Why do local variables require initialization, but fields do not?

If I create a bool within my class, just something like bool check, it defaults to false. When I create …

c# language-design local-variables
Using locals() and format() method for strings: are there any caveats?

Are there any disadvantages, caveats or bad practice warnings about using the following pattern? def buildString(user, name = 'john', age=22): …

python string-formatting local-variables locals
how refer to a local variable share same name of a global variable in C?

for example #include<stdio.h> int foo = 100; int bar() { int foo; /* local foo = global foo, how to implemented? */ …

c global-variables scope local-variables
Is it reasonable to synchronize on a local variable?

From the Java memory model, we know that every thread has its own thread stack, and that local variables are …

java multithreading synchronization local-variables
How to dynamically define a class method which will refer to a local variable outside?

class C end var = "I am a local var outside" C.class_eval do def self.a_class_method puts …

ruby dynamic closures class-method local-variables
Lambda assigning local variables

Consider the following source: static void Main(string[] args) { bool test; Action lambda = () => { test = true; }; lambda(); if (test) Console.…

c# c++ lambda compiler-errors local-variables