Variable
A variable is a named location that holds a value.
Related concepts: NameValueAssignment
Closest Wikipedia entry: Variable (computer science)
Misconceptions about Variable35 documented Misconceptions
Check YourselfAssignmentCopiesObject — Java
Assignment copies the object
CallerFrameContainsCalleeFormal — Java
Stack frame of caller includes variables for callee's formal parameters
ControlledLocalAccess — Java
One can control access to local variables using access modifiers
ExpressionAssigns — Java
An expression that reads a variable also updates its value after the evaluation
ForEachIteratesOverIndices — Java
An enhanced for loop iterates over the indices of an array or a collection
ForEachVariableIsElement — Java
One can assign to the variable of an enhanced for statement to store a value in the corresponding array or collection element
ForVariableScopeBeyondLoop — Java
The scope of variables declared in a for loop header extends beyond the loop
LocalVariablesAutoInitialized — Java
Local variables are automatically initialized
LoopBodyScopeImpliesLoopLifetime — Java
Lifetime of variables declared in a loop body extends across all loop iterations
MultiReferenceVariable — Java
A reference variable can point to multiple objects
MultiValueVariable — Java
A variable can contain more than one value
MustInitializeFieldInConstructor — Java
Constructors must assign values to all fields
NoAtomicExpression — Java
Expressions must consist of more than one piece
NoCastIfSameSize — Java
If a variable is at least as big (bit-width) as a value, then no cast is needed to a assign the value to the variable
NoLocalVariables — Java
There are no local variables
ReferenceToVariable — Java
References can point to variables
ThisAsField — Java
this is a special field in the object
ThisAssignable — Java
One can assign to this
ThisExistsInStaticMethod — Java
this is a local variable, also in static methods
UndeclaredVariables — Java
Variables can be used even without being declared beforehand
UntypedVariables — Java
Variable declarations don't need a type
UseOfSelfTypeImpliesRecursiveType — Java
If a class has a method that has a local variable, parameter, or return value with the class as its type, the class is a recursive type
VariablesHoldExpressions — Java
= stores an expression in a variable
VariablesHoldObjects — Java
A variable of a reference type contains a whole object
AssignmentCopiesObject — JavaScript
Assignment copies the object
ConstDeclarationCanBeLeftUninitialized — JavaScript
Declarations of constants do not need to be immediately initialized
NoAtomicExpression — JavaScript
Expressions must consist of more than one piece
ThisAssignable — JavaScript
One can assign to this
AssignmentCopiesObject — Python
Assignment copies the object
NoAtomicExpression — Python
Expressions must consist of more than one piece
SelfAssignable — Python
Reassigning self changes the object on which a method is called
VariablesHoldExpressions — Python
= stores an expression: it stores a reference to the expression in a variable
VariablesHoldObjects — Python
A variable contains a whole object
ExpressionAssigns — Scratch
An expression that reads a variable also updates its value after the evaluation
ResetStateEachProgramExecution — Scratch
Running a Scratch program first resets the state of the world and then executes the program