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
Assignment copies the object
CallerFrameContainsCalleeFormal
Stack frame of caller includes variables for callee's formal parameters
ControlledLocalAccess
One can control access to local variables using access modifiers
ExpressionAssigns
An expression that reads a variable also updates its value after the evaluation
ForEachIteratesOverIndices
An enhanced for loop iterates over the indices of an array or a collection
ForEachVariableIsElement
One can assign to the variable of an enhanced for statement to store a value in the corresponding array or collection element
ForVariableScopeBeyondLoop
The scope of variables declared in a for loop header extends beyond the loop
LocalVariablesAutoInitialized
Local variables are automatically initialized
LoopBodyScopeImpliesLoopLifetime
Lifetime of variables declared in a loop body extends across all loop iterations
MultiReferenceVariable
A reference variable can point to multiple objects
MultiValueVariable
A variable can contain more than one value
MustInitializeFieldInConstructor
Constructors must assign values to all fields
NoAtomicExpression
Expressions must consist of more than one piece
NoCastIfSameSize
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
There are no local variables
ReferenceToVariable
References can point to variables
ThisAsField
this is a special field in the object
ThisAssignable
One can assign to this
ThisExistsInStaticMethod
this is a local variable, also in static methods
UndeclaredVariables
Variables can be used even without being declared beforehand
UntypedVariables
Variable declarations don't need a type
UseOfSelfTypeImpliesRecursiveType
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
= stores an expression in a variable
VariablesHoldObjects
A variable of a reference type contains a whole object