Skip to content
This repository was archived by the owner on Feb 10, 2024. It is now read-only.

Commit 54f489c

Browse files
author
Ram swaroop
committed
added content
1 parent 1e81166 commit 54f489c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

_posts/2015-05-14-variables-and-literals.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,12 +459,23 @@ to any object on the heap.
459459

460460
#### Array Instance Variable
461461

462-
462+
An array is an object, thus, an array instance variable that's declared but not explicitly initialized will have a value
463+
of __`null`__, just as any other object reference instance variable. But if the array is initialized, all array elements
464+
are given their default values, the same default values that elements of that type get when they're instance variables.
465+
In short, __Array elements are always, always, always given default values, regardless of where the array itself
466+
is declared or instantiated__.
467+
468+
Variable Type | Default Value
469+
--------------|----------------
470+
Array (uninitialized) | `null`
471+
Array (initialized) | Default values of their respective types as discussed above
463472

464473
#### Default values for Local (also called Stack or Automatic) variables (Primitive and Non-primitive):
465474

466475

467476

477+
478+
468479
{% include responsive_ad.html %}
469480

470481
### Q&A

0 commit comments

Comments
 (0)