Preserving whitespace

${arrayname[*]}: Does not preserve whitespace in elements.

${arrayname[@]}: Does not preserve whitespace in elements.

"${arrayname[*]}": Does not preserve whitespace in elements.

"${arrayname[@]}": Preserves whitespace in elements.

How to remember?

It is the same as $*, $@, "$*" and "$@".

Remember: Positional parameters

$* / $@: All command-line arguments at once.
"$*" : All command-line arguments as a single string.
"$@" : All command-line arguments as individual strings.

Example

_$: arrayname=("An element" "Another element")

_$: for e in ${arrayname[*]}; do printf "Elem: $e\n"; done
Elem: An
Elem: element
Elem: Another
Elem: element

_$: for e in ${arrayname[@]}; do printf "Elem: $e\n"; done
Elem: An
Elem: element
Elem: Another
Elem: element

_$: for e in "${arrayname[*]}"; do printf "Elem: $e\n"; done
Elem: An element Another element

_$: for e in "${arrayname[@]}"; do printf "Elem: $e\n"; done
Elem: An element
Elem: Another element