In addition to above way, we can also create an array by declare statement.
The declare statement with -a option can be used to declare a variable as an array, but it's not necessary. All variables can be used as arrays without explicit definition. As a matter of fact, it appears that in a sense, all variables are arrays, and that assignment without a subscript is the same as assigning to "". Explicit declaration of an array is done using the declare built-in:
declare -a ARRAYNAME
Associative arrays are created using
declare -A name.
Attributes may be specified for an array variable using the declare and readonly builtins. Each attribute applies to all members of an array.
After you have set any array variable, you access it as follows: