Variable

A variable is a named location that holds a value.

Related concepts:  NameValueAssignment

Closest Wikipedia entry:  Variable (computer science) — In computer programming, a variable or scalar is an abstract storage location paired with an associated symbolic name, which contains some known or unknown quantity of information referred to as a value; or in easy terms, a variable is a container for a particular type of data (like integer, float, String and etc...). A variable can eventually be associated with or identified by a memory address. The variable name is the usual way to reference the stored value, in addition to referring to the variable itself, depending on the context.

Misconceptions about Variable
35 documented Misconceptions

Check Yourself
Misconception
AssignmentCopiesObjectJava
Assignment copies the object
Misconception
AssignmentCopiesObjectJavaScript
Assignment copies the object
Misconception
AssignmentCopiesObjectPython
Assignment copies the object
Misconception
CallerFrameContainsCalleeFormalJava
Stack frame of caller includes variables for callee's formal parameters
Misconception
ConstDeclarationCanBeLeftUninitializedJavaScript
Declarations of constants do not need to be immediately initialized
Misconception
ControlledLocalAccessJava
One can control access to local variables using access modifiers
Misconception
ExpressionAssignsJava
An expression that reads a variable also updates its value after the evaluation
Misconception
ForEachIteratesOverIndicesJava
An enhanced for loop iterates over the indices of an array or a collection
Misconception
ForEachVariableIsElementJava
One can assign to the variable of an enhanced for statement to store a value in the corresponding array or collection element
Misconception
ForVariableScopeBeyondLoopJava
The scope of variables declared in a for loop header extends beyond the loop
Misconception
InlineVariableInExpressionTreeJava
The expression tree of an expression involving a variable inlines the variable's definition
Misconception
LocalVariablesAutoInitializedJava
Local variables are automatically initialized
Misconception
LoopBodyScopeImpliesLoopLifetimeJava
Lifetime of variables declared in a loop body extends across all loop iterations
Misconception
MultiReferenceVariableJava
A reference variable can point to multiple objects
Misconception
MultiValueVariableJava
A variable can contain more than one value
Misconception
MustInitializeFieldInConstructorJava
Constructors must assign values to all fields
Misconception
NoAtomicExpressionJava
Expressions must consist of more than one piece
Misconception
NoAtomicExpressionJavaScript
Expressions must consist of more than one piece
Misconception
NoAtomicExpressionPython
Expressions must consist of more than one piece
Misconception
NoCastIfSameSizeJava
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
Misconception
NoLocalVariablesJava
There are no local variables
Misconception
ObjectLabeledWithVariableNameJava
In stack and heap diagrams, an object on the heap is labeled with the name of the variable that refers to it
Misconception
ReferenceLabeledWithDynamicTypeJava
In stack and heap diagrams, reference variables are labeled with the types of the objects they refer to
Misconception
ReferenceToVariableJava
References can point to variables
Misconception
ThisAsFieldJava
this is a special field in the object
Misconception
ThisAssignableJava
One can assign to this
Misconception
ThisAssignableJavaScript
One can assign to this
Misconception
ThisExistsInStaticMethodJava
this is a local variable, also in static methods
Misconception
UndeclaredVariablesJava
Variables don't need to be declared
Misconception
UntypedVariablesJava
Variable declarations don't need a type
Misconception
UseOfSelfTypeImpliesRecursiveTypeJava
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
Misconception
VariablesHoldExpressionsJava
= stores an expression in a variable
Misconception
VariablesHoldExpressionsPython
= stores an expression: it stores a reference to the expression in a variable
Misconception
VariablesHoldObjectsJava
A variable of a reference type contains a whole object
Misconception
VariablesHoldObjectsPython
A variable contains a whole object

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.